@atzentis/booking-sdk 0.1.5 → 0.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.
package/dist/index.d.cts CHANGED
@@ -538,6 +538,478 @@ declare class AvailabilityService extends BaseService {
538
538
  getPricing(params: PricingParams): Promise<PricingResult>;
539
539
  }
540
540
 
541
+ /**
542
+ * All supported booking types across the three verticals.
543
+ *
544
+ * - **Stays:** `stay`, `dayuse`
545
+ * - **Tables:** `table`
546
+ * - **Services:** `service`
547
+ * - **Universal:** `parking`, `desk`, `meeting`, `custom`
548
+ */
549
+ type BookingType = "stay" | "table" | "service" | "parking" | "desk" | "meeting" | "dayuse" | "custom";
550
+ /** All 8 booking types as a readonly tuple for runtime enumeration */
551
+ declare const BOOKING_TYPES: readonly ["stay", "table", "service", "parking", "desk", "meeting", "dayuse", "custom"];
552
+ /**
553
+ * Booking lifecycle statuses.
554
+ *
555
+ * State machine:
556
+ * ```
557
+ * pending ──→ confirmed ──→ checked_in ──→ checked_out
558
+ * │ │ │
559
+ * ├─→ cancelled ├─→ cancelled ├─→ cancelled
560
+ * ├─→ waitlist └─→ no_show └─→ no_show
561
+ * └─→ no_show
562
+ * ```
563
+ */
564
+ type BookingStatus = "pending" | "confirmed" | "checked_in" | "checked_out" | "cancelled" | "no_show" | "waitlist";
565
+ /** All 7 booking statuses as a readonly tuple for runtime enumeration */
566
+ declare const BOOKING_STATUSES: readonly ["pending", "confirmed", "checked_in", "checked_out", "cancelled", "no_show", "waitlist"];
567
+ /** Guest summary embedded in a booking */
568
+ interface BookingGuest {
569
+ /** Guest identifier */
570
+ id: string;
571
+ /** Guest first name */
572
+ firstName: string;
573
+ /** Guest last name */
574
+ lastName: string;
575
+ /** Guest email address */
576
+ email: string | null;
577
+ /** Guest phone number */
578
+ phone: string | null;
579
+ }
580
+ /** Space summary embedded in a booking */
581
+ interface BookingSpace {
582
+ /** Space identifier */
583
+ id: string;
584
+ /** Display name of the space */
585
+ name: string;
586
+ /** Space type (room, table, service, etc.) */
587
+ type: SpaceType;
588
+ /** Category the space belongs to */
589
+ categoryId: string | null;
590
+ /** Floor the space is on */
591
+ floor: string | null;
592
+ }
593
+ /** Pricing breakdown for a booking */
594
+ interface BookingPricing {
595
+ /** Total price in cents */
596
+ total: number;
597
+ /** Per-night rate in cents, null for non-Stays verticals */
598
+ perNight: number | null;
599
+ /** ISO 4217 currency code (e.g., "EUR", "USD") */
600
+ currency: string;
601
+ /** Tax amount in cents */
602
+ taxes: number;
603
+ /** Fee amount in cents */
604
+ fees: number;
605
+ }
606
+ /** A booking in the Atzentis Booking system */
607
+ interface Booking {
608
+ /** Booking identifier */
609
+ id: string;
610
+ /** Human-readable confirmation code */
611
+ confirmationCode: string;
612
+ /** Property this booking belongs to */
613
+ propertyId: string;
614
+ /** Category for the booked space */
615
+ categoryId: string | null;
616
+ /** Guest who made the booking */
617
+ guestId: string;
618
+ /** Assigned space, null until assigned */
619
+ spaceId: string | null;
620
+ /** Booking type */
621
+ type: BookingType;
622
+ /** Current lifecycle status */
623
+ status: BookingStatus;
624
+ /** Check-in date in YYYY-MM-DD format */
625
+ checkIn: string;
626
+ /** Check-out date in YYYY-MM-DD format */
627
+ checkOut: string;
628
+ /** Number of guests */
629
+ guests: number;
630
+ /** Free-text notes */
631
+ notes: string | null;
632
+ /** Booking source (e.g., "website", "phone", "walk-in") */
633
+ source: string | null;
634
+ /** Rate plan identifier */
635
+ rateId: string | null;
636
+ /** Open bag for custom data */
637
+ metadata: Record<string, unknown> | null;
638
+ /** Guest summary */
639
+ guest: BookingGuest | null;
640
+ /** Assigned space summary */
641
+ space: BookingSpace | null;
642
+ /** Pricing breakdown */
643
+ pricing: BookingPricing | null;
644
+ /** When the booking was confirmed */
645
+ confirmedAt: string | null;
646
+ /** When the guest checked in */
647
+ checkedInAt: string | null;
648
+ /** When the guest checked out */
649
+ checkedOutAt: string | null;
650
+ /** When the booking was cancelled */
651
+ cancelledAt: string | null;
652
+ /** Cancellation reason, populated on cancel */
653
+ cancellationReason: string | null;
654
+ /** When the booking was marked as no-show */
655
+ noShowAt: string | null;
656
+ /** Record creation timestamp */
657
+ createdAt: string;
658
+ /** Record last-update timestamp */
659
+ updatedAt: string;
660
+ }
661
+ /** Input for creating a new booking */
662
+ interface CreateBookingInput {
663
+ /** Property to create the booking for */
664
+ propertyId: string;
665
+ /** Category for the booked space */
666
+ categoryId: string;
667
+ /** Guest identifier */
668
+ guestId: string;
669
+ /** Check-in date in YYYY-MM-DD format */
670
+ checkIn: string;
671
+ /** Check-out date in YYYY-MM-DD format */
672
+ checkOut: string;
673
+ /** Booking type */
674
+ type: BookingType;
675
+ /** Number of guests */
676
+ guests?: number;
677
+ /** Assign a specific space */
678
+ spaceId?: string;
679
+ /** Free-text notes */
680
+ notes?: string;
681
+ /** Booking source */
682
+ source?: string;
683
+ /** Rate plan identifier */
684
+ rateId?: string;
685
+ /** Custom metadata */
686
+ metadata?: Record<string, unknown>;
687
+ /** Auto-confirm the booking on creation */
688
+ autoConfirm?: boolean;
689
+ }
690
+ /** Input for updating an existing booking — all fields optional */
691
+ interface UpdateBookingInput {
692
+ /** Update the category */
693
+ categoryId?: string;
694
+ /** Update check-in date */
695
+ checkIn?: string;
696
+ /** Update check-out date */
697
+ checkOut?: string;
698
+ /** Update number of guests */
699
+ guests?: number;
700
+ /** Update notes */
701
+ notes?: string;
702
+ /** Update source */
703
+ source?: string;
704
+ /** Update rate plan */
705
+ rateId?: string;
706
+ /** Update metadata */
707
+ metadata?: Record<string, unknown>;
708
+ }
709
+ /** Input for check-in operation */
710
+ interface CheckInInput {
711
+ /** Actual arrival time in ISO 8601 format */
712
+ actualArrival?: string;
713
+ /** Check-in notes */
714
+ notes?: string;
715
+ /** Assign or change space at check-in */
716
+ spaceId?: string;
717
+ }
718
+ /** Input for check-out operation */
719
+ interface CheckOutInput {
720
+ /** Actual departure time in ISO 8601 format */
721
+ actualDeparture?: string;
722
+ /** Check-out notes */
723
+ notes?: string;
724
+ }
725
+ /** Input for cancel operation */
726
+ interface CancelBookingInput {
727
+ /** Cancellation reason (required) */
728
+ reason: string;
729
+ /** Who cancelled the booking */
730
+ cancelledBy?: string;
731
+ /** Whether a refund was requested */
732
+ refundRequested?: boolean;
733
+ }
734
+ /** Input for no-show operation */
735
+ interface NoShowInput {
736
+ /** No-show notes */
737
+ notes?: string;
738
+ /** Whether to charge a no-show fee */
739
+ chargeNoShowFee?: boolean;
740
+ }
741
+ /** Input for space assignment */
742
+ interface AssignSpaceInput {
743
+ /** Space to assign (required) */
744
+ spaceId: string;
745
+ /** Assignment notes */
746
+ notes?: string;
747
+ }
748
+ /** Sort configuration for booking list queries */
749
+ interface BookingSort {
750
+ /** Field to sort by */
751
+ field: "checkIn" | "checkOut" | "createdAt" | "updatedAt" | "status";
752
+ /** Sort direction */
753
+ direction: "asc" | "desc";
754
+ }
755
+ /** Query parameters for listing bookings */
756
+ interface ListBookingsParams {
757
+ /** Property to list bookings for (required) */
758
+ propertyId: string;
759
+ /** Filter by status (single or array) */
760
+ status?: BookingStatus | BookingStatus[];
761
+ /** Filter by type (single or array) */
762
+ type?: BookingType | BookingType[];
763
+ /** Filter by guest */
764
+ guestId?: string;
765
+ /** Filter by check-in date (from) */
766
+ checkInFrom?: string;
767
+ /** Filter by check-in date (to) */
768
+ checkInTo?: string;
769
+ /** Filter by check-out date (from) */
770
+ checkOutFrom?: string;
771
+ /** Filter by check-out date (to) */
772
+ checkOutTo?: string;
773
+ /** Search by confirmation code or guest name */
774
+ search?: string;
775
+ /** Sort configuration */
776
+ sort?: BookingSort;
777
+ /** Maximum results per page */
778
+ limit?: number;
779
+ /** Pagination cursor */
780
+ cursor?: string;
781
+ }
782
+ /** Paginated list of bookings */
783
+ interface PaginatedBookings {
784
+ /** Bookings in this page */
785
+ data: Booking[];
786
+ /** Total number of matching bookings */
787
+ totalCount: number;
788
+ /** Cursor for next page, null if no more results */
789
+ cursor: string | null;
790
+ /** Whether more results are available */
791
+ hasMore: boolean;
792
+ }
793
+
794
+ /**
795
+ * Service for managing bookings in the Atzentis Booking API.
796
+ *
797
+ * Provides full CRUD operations and lifecycle management across all
798
+ * 8 booking types (stay, table, service, parking, desk, meeting, dayuse, custom)
799
+ * and 7 statuses (pending, confirmed, checked_in, checked_out, cancelled, no_show, waitlist).
800
+ *
801
+ * **Lifecycle state machine:**
802
+ * ```
803
+ * pending ──→ confirmed ──→ checked_in ──→ checked_out
804
+ * │ │ │
805
+ * ├─→ cancelled ├─→ cancelled ├─→ cancelled
806
+ * ├─→ waitlist └─→ no_show └─→ no_show
807
+ * └─→ no_show
808
+ * ```
809
+ *
810
+ * @example
811
+ * ```typescript
812
+ * const booking = new BookingClient({ apiKey: "atz_io_live_xxxxx" });
813
+ *
814
+ * // Create a stay booking
815
+ * const newBooking = await booking.bookings.create({
816
+ * propertyId: "prop_abc123",
817
+ * categoryId: "cat_deluxe",
818
+ * guestId: "guest_42",
819
+ * checkIn: "2025-07-01",
820
+ * checkOut: "2025-07-05",
821
+ * type: "stay",
822
+ * });
823
+ *
824
+ * // Lifecycle: confirm → check-in → check-out
825
+ * await booking.bookings.confirm(newBooking.id);
826
+ * await booking.bookings.checkIn(newBooking.id);
827
+ * await booking.bookings.checkOut(newBooking.id);
828
+ * ```
829
+ */
830
+ declare class BookingsService extends BaseService {
831
+ protected readonly basePath = "/booking/v1/bookings";
832
+ /**
833
+ * Create a new booking.
834
+ *
835
+ * @example
836
+ * ```typescript
837
+ * const booking = await client.bookings.create({
838
+ * propertyId: "prop_abc123",
839
+ * categoryId: "cat_deluxe",
840
+ * guestId: "guest_42",
841
+ * checkIn: "2025-07-01",
842
+ * checkOut: "2025-07-05",
843
+ * type: "stay",
844
+ * guests: 2,
845
+ * autoConfirm: true,
846
+ * });
847
+ * ```
848
+ */
849
+ create(input: CreateBookingInput): Promise<Booking>;
850
+ /**
851
+ * Get a single booking by ID.
852
+ *
853
+ * @example
854
+ * ```typescript
855
+ * const booking = await client.bookings.get("bk_abc123");
856
+ * ```
857
+ */
858
+ get(bookingId: string): Promise<Booking>;
859
+ /**
860
+ * List bookings for a property with optional filters and cursor-based pagination.
861
+ *
862
+ * Supports filtering by status, type, guest, date ranges, search term,
863
+ * and custom sort order. Array values for `status` and `type` are serialized
864
+ * as comma-separated strings.
865
+ *
866
+ * @example
867
+ * ```typescript
868
+ * // List all confirmed stay bookings
869
+ * const page = await client.bookings.list({
870
+ * propertyId: "prop_abc123",
871
+ * status: "confirmed",
872
+ * type: "stay",
873
+ * });
874
+ *
875
+ * // Multi-status filter with date range
876
+ * const page2 = await client.bookings.list({
877
+ * propertyId: "prop_abc123",
878
+ * status: ["confirmed", "checked_in"],
879
+ * checkInFrom: "2025-07-01",
880
+ * checkInTo: "2025-07-31",
881
+ * sort: { field: "checkIn", direction: "asc" },
882
+ * limit: 20,
883
+ * });
884
+ * ```
885
+ */
886
+ list(params: ListBookingsParams): Promise<PaginatedBookings>;
887
+ /**
888
+ * Update an existing booking.
889
+ *
890
+ * @example
891
+ * ```typescript
892
+ * const updated = await client.bookings.update("bk_abc123", {
893
+ * guests: 3,
894
+ * notes: "Extra bed requested",
895
+ * });
896
+ * ```
897
+ */
898
+ update(bookingId: string, input: UpdateBookingInput): Promise<Booking>;
899
+ /**
900
+ * Delete a booking.
901
+ *
902
+ * @example
903
+ * ```typescript
904
+ * await client.bookings.delete("bk_abc123");
905
+ * ```
906
+ */
907
+ delete(bookingId: string): Promise<void>;
908
+ /**
909
+ * Confirm a pending booking.
910
+ *
911
+ * Transitions: `pending` → `confirmed`
912
+ *
913
+ * @throws {ConflictError} 409 if the booking is not in `pending` status
914
+ *
915
+ * @example
916
+ * ```typescript
917
+ * const confirmed = await client.bookings.confirm("bk_abc123");
918
+ * // confirmed.status === "confirmed"
919
+ * // confirmed.confirmedAt is populated
920
+ * ```
921
+ */
922
+ confirm(bookingId: string): Promise<Booking>;
923
+ /**
924
+ * Check in a guest.
925
+ *
926
+ * Transitions: `confirmed` → `checked_in`
927
+ *
928
+ * @throws {ConflictError} 409 if the booking is not in `confirmed` status
929
+ *
930
+ * @example
931
+ * ```typescript
932
+ * const checkedIn = await client.bookings.checkIn("bk_abc123", {
933
+ * actualArrival: "2025-07-01T14:30:00Z",
934
+ * });
935
+ * // checkedIn.status === "checked_in"
936
+ * // checkedIn.checkedInAt is populated
937
+ * ```
938
+ */
939
+ checkIn(bookingId: string, input?: CheckInInput): Promise<Booking>;
940
+ /**
941
+ * Check out a guest.
942
+ *
943
+ * Transitions: `checked_in` → `checked_out`
944
+ *
945
+ * @throws {ConflictError} 409 if the booking is not in `checked_in` status
946
+ *
947
+ * @example
948
+ * ```typescript
949
+ * const checkedOut = await client.bookings.checkOut("bk_abc123", {
950
+ * actualDeparture: "2025-07-05T11:00:00Z",
951
+ * });
952
+ * // checkedOut.status === "checked_out"
953
+ * // checkedOut.checkedOutAt is populated
954
+ * ```
955
+ */
956
+ checkOut(bookingId: string, input?: CheckOutInput): Promise<Booking>;
957
+ /**
958
+ * Cancel a booking.
959
+ *
960
+ * Transitions: `pending` | `confirmed` | `checked_in` → `cancelled`
961
+ *
962
+ * @throws {ConflictError} 409 if the booking is already cancelled, checked out, or no-show
963
+ *
964
+ * @example
965
+ * ```typescript
966
+ * const cancelled = await client.bookings.cancel("bk_abc123", {
967
+ * reason: "Guest requested cancellation",
968
+ * refundRequested: true,
969
+ * });
970
+ * // cancelled.status === "cancelled"
971
+ * // cancelled.cancelledAt is populated
972
+ * // cancelled.cancellationReason === "Guest requested cancellation"
973
+ * ```
974
+ */
975
+ cancel(bookingId: string, input: CancelBookingInput): Promise<Booking>;
976
+ /**
977
+ * Mark a booking as no-show.
978
+ *
979
+ * Transitions: `pending` | `confirmed` | `checked_in` → `no_show`
980
+ *
981
+ * @throws {ConflictError} 409 if the booking is already checked out, cancelled, or no-show
982
+ *
983
+ * @example
984
+ * ```typescript
985
+ * const noShow = await client.bookings.noShow("bk_abc123", {
986
+ * chargeNoShowFee: true,
987
+ * });
988
+ * // noShow.status === "no_show"
989
+ * // noShow.noShowAt is populated
990
+ * ```
991
+ */
992
+ noShow(bookingId: string, input?: NoShowInput): Promise<Booking>;
993
+ /**
994
+ * Assign or reassign a space to a booking.
995
+ *
996
+ * Can be called on any active booking (pending, confirmed, checked_in).
997
+ *
998
+ * @throws {ConflictError} 409 if the booking is in a terminal status
999
+ *
1000
+ * @example
1001
+ * ```typescript
1002
+ * const assigned = await client.bookings.assignSpace("bk_abc123", {
1003
+ * spaceId: "spc_room101",
1004
+ * notes: "Upgraded to deluxe",
1005
+ * });
1006
+ * // assigned.spaceId === "spc_room101"
1007
+ * // assigned.space is populated
1008
+ * ```
1009
+ */
1010
+ assignSpace(bookingId: string, input: AssignSpaceInput): Promise<Booking>;
1011
+ }
1012
+
541
1013
  /** All supported property types in the v4.0 API */
542
1014
  type PropertyType = "hotel" | "resort" | "villa" | "apartment" | "hostel" | "bnb" | "restaurant" | "cafe" | "bar" | "beach" | "spa" | "salon" | "custom";
543
1015
  /** Property lifecycle status */
@@ -945,12 +1417,15 @@ declare class SpacesService extends BaseService {
945
1417
  declare class BookingClient {
946
1418
  readonly httpClient: HttpClient;
947
1419
  private _availability?;
1420
+ private _bookings?;
948
1421
  private _properties?;
949
1422
  private _categories?;
950
1423
  private _spaces?;
951
1424
  constructor(config: BookingClientConfig);
952
1425
  /** Availability service — lazy-initialized on first access */
953
1426
  get availability(): AvailabilityService;
1427
+ /** Bookings service — lazy-initialized on first access */
1428
+ get bookings(): BookingsService;
954
1429
  /** Properties service — lazy-initialized on first access */
955
1430
  get properties(): PropertiesService;
956
1431
  /** Categories service — lazy-initialized on first access */
@@ -1039,4 +1514,4 @@ declare function firstPage<T>(fetcher: PageFetcher<T>, options?: PaginationOptio
1039
1514
 
1040
1515
  declare const VERSION = "0.1.0";
1041
1516
 
1042
- export { AuthenticationError, type AvailabilityCheckParams, type AvailabilityPricing, type AvailabilityRestrictions, type AvailabilityResult, type AvailabilitySearchParams, type AvailabilitySearchResult, type AvailabilitySearchResultEntry, AvailabilityService, type AvailableSpace, BookingClient, type BookingClientConfig, BookingError, type BookingErrorOptions, type BulkUpdateSpaceInput, type CalendarDay, type CalendarParams, CategoriesService, ConflictError, type Coordinates, type CreateCategoryInput, type CreatePropertyInput, type CreateSpaceInput, DEFAULT_MODULES, ForbiddenError, HttpClient, type HttpClientOptions, type HttpMethod, type HttpResponse, type LinkPosTableInput, type ListCategoriesParams, type ListPropertiesParams, type ListSpacesParams, type Logger, NotFoundError, PROPERTY_MODULES, type PageFetcher, type Paginated, type PaginationOptions, PaymentError, type PriceRange, type PricingParams, type PricingResult, PropertiesService, type Property, type PropertyAddress, type PropertyModules, type PropertyStatus, type PropertyType, RateLimitError, type RequestOptions, type ResolvedBookingClientConfig, type RetryConfig, type RetryOptions, SPACE_STATUSES, SPACE_TYPES, ServerError, type ServiceSlotParams, type ServiceTimeSlot, type Space, type SpaceCategory, type SpaceStatus, type SpaceType, SpacesService, type TableSlotParams, type TimeSlot, TimeoutError, type UpdateCategoryInput, type UpdatePropertyInput, type UpdateSpaceInput, VERSION, ValidationError, bookingClientConfigSchema, createErrorFromResponse, firstPage, paginate };
1517
+ export { type AssignSpaceInput, AuthenticationError, type AvailabilityCheckParams, type AvailabilityPricing, type AvailabilityRestrictions, type AvailabilityResult, type AvailabilitySearchParams, type AvailabilitySearchResult, type AvailabilitySearchResultEntry, AvailabilityService, type AvailableSpace, BOOKING_STATUSES, BOOKING_TYPES, type Booking, BookingClient, type BookingClientConfig, BookingError, type BookingErrorOptions, type BookingGuest, type BookingPricing, type BookingSort, type BookingSpace, type BookingStatus, type BookingType, BookingsService, type BulkUpdateSpaceInput, type CalendarDay, type CalendarParams, type CancelBookingInput, CategoriesService, type CheckInInput, type CheckOutInput, ConflictError, type Coordinates, type CreateBookingInput, type CreateCategoryInput, type CreatePropertyInput, type CreateSpaceInput, DEFAULT_MODULES, ForbiddenError, HttpClient, type HttpClientOptions, type HttpMethod, type HttpResponse, type LinkPosTableInput, type ListBookingsParams, type ListCategoriesParams, type ListPropertiesParams, type ListSpacesParams, type Logger, type NoShowInput, NotFoundError, PROPERTY_MODULES, type PageFetcher, type Paginated, type PaginatedBookings, type PaginationOptions, PaymentError, type PriceRange, type PricingParams, type PricingResult, PropertiesService, type Property, type PropertyAddress, type PropertyModules, type PropertyStatus, type PropertyType, RateLimitError, type RequestOptions, type ResolvedBookingClientConfig, type RetryConfig, type RetryOptions, SPACE_STATUSES, SPACE_TYPES, ServerError, type ServiceSlotParams, type ServiceTimeSlot, type Space, type SpaceCategory, type SpaceStatus, type SpaceType, SpacesService, type TableSlotParams, type TimeSlot, TimeoutError, type UpdateBookingInput, type UpdateCategoryInput, type UpdatePropertyInput, type UpdateSpaceInput, VERSION, ValidationError, bookingClientConfigSchema, createErrorFromResponse, firstPage, paginate };