@atzentis/booking-sdk 0.1.4 → 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
@@ -94,6 +94,277 @@ declare class HttpClient {
94
94
  private buildHeaders;
95
95
  }
96
96
 
97
+ /**
98
+ * All supported space types in the v4.0 API.
99
+ *
100
+ * Grouped by vertical:
101
+ * - **Stays:** `room`, `sunbed`, `parking`
102
+ * - **Tables:** `table`, `locker`
103
+ * - **Services:** `service`, `meeting_room`, `desk`
104
+ * - **Universal:** `custom`
105
+ */
106
+ type SpaceType = "room" | "table" | "sunbed" | "parking" | "desk" | "meeting_room" | "locker" | "service" | "custom";
107
+ /** All 9 space types as a readonly tuple for runtime enumeration */
108
+ declare const SPACE_TYPES: readonly ["room", "table", "sunbed", "parking", "desk", "meeting_room", "locker", "service", "custom"];
109
+ /** Space availability/lifecycle status */
110
+ type SpaceStatus = "available" | "occupied" | "maintenance" | "blocked" | "inactive";
111
+ /** All 5 space statuses as a readonly tuple for runtime enumeration */
112
+ declare const SPACE_STATUSES: readonly ["available", "occupied", "maintenance", "blocked", "inactive"];
113
+ /** A bookable space in the Atzentis Booking system */
114
+ interface Space {
115
+ id: string;
116
+ propertyId: string;
117
+ categoryId: string | null;
118
+ name: string;
119
+ type: SpaceType;
120
+ status: SpaceStatus;
121
+ /** Used for rooms (hotel floor) and desks/meeting rooms (office floor). Use string to support labels like "B1", "G", "1", "2". */
122
+ floor: string | null;
123
+ /** Used for tables (cover count) and meeting rooms (person count). Null if not applicable. */
124
+ capacity: number | null;
125
+ /** POS table reference; set via `linkPosTable()`. Tables vertical only. Null until linked. */
126
+ posTableId: string | null;
127
+ /** Open bag for vertical-specific extras not covered by standard fields. Schema is consumer-defined. */
128
+ metadata: Record<string, unknown> | null;
129
+ createdAt: string;
130
+ updatedAt: string;
131
+ }
132
+ /** Input for creating a new space */
133
+ interface CreateSpaceInput {
134
+ propertyId: string;
135
+ name: string;
136
+ type: SpaceType;
137
+ categoryId?: string;
138
+ /** Optional. See `Space.floor` for usage by vertical. */
139
+ floor?: string;
140
+ /** Optional. See `Space.capacity` for usage by vertical. */
141
+ capacity?: number;
142
+ /** Optional. See `Space.metadata` for usage by vertical. */
143
+ metadata?: Record<string, unknown>;
144
+ }
145
+ /** Input for updating an existing space — all fields optional */
146
+ type UpdateSpaceInput = Partial<Omit<CreateSpaceInput, "propertyId">>;
147
+ /** Input for bulk updating spaces — requires `id` to identify each space */
148
+ type BulkUpdateSpaceInput = UpdateSpaceInput & {
149
+ id: string;
150
+ };
151
+ /** Input for linking a space to a POS table */
152
+ interface LinkPosTableInput {
153
+ posTableId: string;
154
+ }
155
+ /** Query parameters for listing spaces — propertyId is required */
156
+ interface ListSpacesParams {
157
+ propertyId: string;
158
+ type?: SpaceType;
159
+ status?: SpaceStatus;
160
+ categoryId?: string;
161
+ floor?: number | string;
162
+ limit?: number;
163
+ cursor?: string;
164
+ }
165
+
166
+ /** Parameters for checking availability of a specific property */
167
+ interface AvailabilityCheckParams {
168
+ /** Property to check availability for */
169
+ propertyId: string;
170
+ /** Check-in date in YYYY-MM-DD format */
171
+ checkIn: string;
172
+ /** Check-out date in YYYY-MM-DD format */
173
+ checkOut: string;
174
+ /** Filter by space category */
175
+ categoryId?: string;
176
+ /** Check a specific space */
177
+ spaceId?: string;
178
+ /** Number of guests */
179
+ guests?: number;
180
+ /** Filter by space type */
181
+ type?: SpaceType;
182
+ }
183
+ /** Result of an availability check */
184
+ interface AvailabilityResult {
185
+ /** Whether any spaces are available for the requested dates */
186
+ available: boolean;
187
+ /** Available spaces matching the criteria */
188
+ spaces: AvailableSpace[];
189
+ /** Pricing details for the available spaces, null if not available */
190
+ pricing: AvailabilityPricing | null;
191
+ /** Stay restrictions, null if none apply */
192
+ restrictions: AvailabilityRestrictions | null;
193
+ }
194
+ /** A single available space from an availability check */
195
+ interface AvailableSpace {
196
+ /** Space identifier */
197
+ spaceId: string;
198
+ /** Category the space belongs to */
199
+ categoryId: string | null;
200
+ /** Display name of the space */
201
+ name: string;
202
+ /** Space type (room, table, service, etc.) */
203
+ type: SpaceType;
204
+ /** Price in cents */
205
+ price: number;
206
+ /** Whether this specific space is available */
207
+ available: boolean;
208
+ }
209
+ /** Pricing breakdown from an availability check */
210
+ interface AvailabilityPricing {
211
+ /** Total price in cents */
212
+ total: number;
213
+ /** Per-night rate in cents, null for non-Stays verticals */
214
+ perNight: number | null;
215
+ /** ISO 4217 currency code (e.g., "EUR", "USD") */
216
+ currency: string;
217
+ }
218
+ /** Stay restriction rules */
219
+ interface AvailabilityRestrictions {
220
+ /** Minimum stay duration in nights */
221
+ minStay: number | null;
222
+ /** Maximum stay duration in nights */
223
+ maxStay: number | null;
224
+ /** Whether arrivals are blocked on this date */
225
+ closedToArrival: boolean;
226
+ /** Whether departures are blocked on this date */
227
+ closedToDeparture: boolean;
228
+ }
229
+ /** Parameters for searching availability across multiple properties */
230
+ interface AvailabilitySearchParams {
231
+ /** Property IDs to search across */
232
+ propertyIds: string[];
233
+ /** Check-in date in YYYY-MM-DD format */
234
+ checkIn: string;
235
+ /** Check-out date in YYYY-MM-DD format */
236
+ checkOut: string;
237
+ /** Number of guests */
238
+ guests?: number;
239
+ /** Filter by space type */
240
+ type?: SpaceType;
241
+ /** Price range filter */
242
+ priceRange?: PriceRange;
243
+ /** Filter by category IDs */
244
+ categoryIds?: string[];
245
+ /** Maximum results per page */
246
+ limit?: number;
247
+ /** Pagination cursor */
248
+ cursor?: string;
249
+ }
250
+ /** Price range filter with min/max in cents */
251
+ interface PriceRange {
252
+ /** Minimum price in cents */
253
+ min?: number;
254
+ /** Maximum price in cents */
255
+ max?: number;
256
+ }
257
+ /** Result of a multi-property availability search */
258
+ interface AvailabilitySearchResult {
259
+ /** Matching properties with availability */
260
+ results: AvailabilitySearchResultEntry[];
261
+ /** Total number of matching properties */
262
+ totalCount: number;
263
+ /** Cursor for next page, null if no more results */
264
+ cursor: string | null;
265
+ /** Whether more results are available */
266
+ hasMore: boolean;
267
+ }
268
+ /** A single property's availability in a search result */
269
+ interface AvailabilitySearchResultEntry {
270
+ /** Property identifier */
271
+ propertyId: string;
272
+ /** Available spaces at this property */
273
+ spaces: AvailableSpace[];
274
+ /** Lowest price in cents among available spaces */
275
+ bestPrice: number;
276
+ }
277
+ /** Parameters for generating a calendar view */
278
+ interface CalendarParams extends AvailabilityCheckParams {
279
+ /** Number of months to generate (default: 1). Each month is 30 days. */
280
+ months?: number;
281
+ }
282
+ /** A single day in a calendar view */
283
+ interface CalendarDay {
284
+ /** Date in YYYY-MM-DD format */
285
+ date: string;
286
+ /** Whether spaces are available on this date */
287
+ available: boolean;
288
+ /** Price in cents for this date, null if unavailable */
289
+ price: number | null;
290
+ /** Minimum stay requirement in nights, null if none */
291
+ minStay: number | null;
292
+ /** Whether arrivals are blocked on this date */
293
+ closedToArrival: boolean;
294
+ /** Whether departures are blocked on this date */
295
+ closedToDeparture: boolean;
296
+ /** Number of spaces available on this date */
297
+ spacesAvailable: number;
298
+ }
299
+ /** Parameters for querying table time slots */
300
+ interface TableSlotParams {
301
+ /** Property to query */
302
+ propertyId: string;
303
+ /** Date to check in YYYY-MM-DD format */
304
+ date: string;
305
+ /** Number of guests (filters by table capacity) */
306
+ guests?: number;
307
+ /** Filter by table category (e.g., indoor, outdoor) */
308
+ categoryId?: string;
309
+ /** Reservation duration in minutes (default: 90) */
310
+ duration?: number;
311
+ }
312
+ /** Parameters for querying service appointment slots */
313
+ interface ServiceSlotParams {
314
+ /** Property to query */
315
+ propertyId: string;
316
+ /** Date to check in YYYY-MM-DD format */
317
+ date: string;
318
+ /** Filter by specific provider/staff member */
319
+ providerId?: string;
320
+ /** Filter by service category */
321
+ categoryId?: string;
322
+ /** Appointment duration in minutes */
323
+ duration?: number;
324
+ }
325
+ /** A time slot for table reservations */
326
+ interface TimeSlot {
327
+ /** Start time in HH:MM format (24-hour) */
328
+ startTime: string;
329
+ /** End time in HH:MM format (24-hour) */
330
+ endTime: string;
331
+ /** Whether this slot is available */
332
+ available: boolean;
333
+ /** Number of tables available in this slot */
334
+ tablesAvailable: number;
335
+ /** Price in cents for this slot, null if not priced */
336
+ price: number | null;
337
+ }
338
+ /** A time slot for service appointments, extends TimeSlot with provider info */
339
+ interface ServiceTimeSlot extends TimeSlot {
340
+ /** Provider/staff member identifier */
341
+ providerId: string;
342
+ /** Display name of the provider */
343
+ providerName: string;
344
+ }
345
+ /** Parameters for pricing aggregation */
346
+ interface PricingParams extends AvailabilityCheckParams {
347
+ /** ISO 4217 currency code override (default: property currency) */
348
+ currency?: string;
349
+ }
350
+ /** Aggregated pricing statistics */
351
+ interface PricingResult {
352
+ /** Lowest price in cents among available spaces */
353
+ minPrice: number;
354
+ /** Highest price in cents among available spaces */
355
+ maxPrice: number;
356
+ /** Mean price in cents (rounded to integer) */
357
+ averagePrice: number;
358
+ /** Total price in cents for the full stay/booking */
359
+ totalPrice: number;
360
+ /** Per-night rate in cents, null for Tables/Services */
361
+ perNight: number | null;
362
+ /** Number of nights (date difference), 0 for same-day */
363
+ nights: number;
364
+ /** ISO 4217 currency code */
365
+ currency: string;
366
+ }
367
+
97
368
  /** The standard paginated response shape returned by all v4.0 list endpoints */
98
369
  interface Paginated<T> {
99
370
  /** The items for this page */
@@ -113,6 +384,632 @@ interface PaginationOptions {
113
384
  /** Callback type: a function that fetches one page given current cursor options */
114
385
  type PageFetcher<T> = (options: PaginationOptions) => Promise<Paginated<T>>;
115
386
 
387
+ /**
388
+ * Abstract base class for all SDK services.
389
+ * Provides typed HTTP helper methods and path construction.
390
+ * Not exported from the public API.
391
+ */
392
+ declare abstract class BaseService {
393
+ protected readonly http: HttpClient;
394
+ protected abstract readonly basePath: string;
395
+ constructor(http: HttpClient);
396
+ /** Build a full path from the base path and additional segments */
397
+ protected _buildPath(...segments: string[]): string;
398
+ /** GET request returning typed response */
399
+ protected _get<T>(path: string, query?: Record<string, string | number | boolean | null | undefined>): Promise<T>;
400
+ /** POST request with body, returning typed response */
401
+ protected _post<T>(path: string, body: unknown): Promise<T>;
402
+ /** PATCH request with body, returning typed response */
403
+ protected _patch<T>(path: string, body: unknown): Promise<T>;
404
+ /** DELETE request, returning void */
405
+ protected _delete(path: string): Promise<void>;
406
+ /** GET list request with optional query params, returning paginated response */
407
+ protected _list<T>(params?: any): Promise<Paginated<T>>;
408
+ }
409
+
410
+ /**
411
+ * Service for checking and searching availability in the Atzentis Booking API.
412
+ *
413
+ * Provides two API endpoints (`check` and `search`) plus four client-side helper
414
+ * methods for calendar views, table time-slots, service appointment slots, and
415
+ * pricing aggregation.
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * const booking = new BookingClient({ apiKey: "atz_io_live_xxxxx" });
420
+ *
421
+ * // Check availability for a property
422
+ * const result = await booking.availability.check({
423
+ * propertyId: "prop_abc123",
424
+ * checkIn: "2025-06-01",
425
+ * checkOut: "2025-06-05",
426
+ * });
427
+ * ```
428
+ */
429
+ declare class AvailabilityService extends BaseService {
430
+ protected readonly basePath = "/booking/v1/availability";
431
+ /**
432
+ * Check availability for a property and date range.
433
+ *
434
+ * @param params - Must include `propertyId`, `checkIn`, `checkOut`; supports optional filters
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * const result = await booking.availability.check({
439
+ * propertyId: "prop_abc123",
440
+ * checkIn: "2025-06-01",
441
+ * checkOut: "2025-06-05",
442
+ * type: "room",
443
+ * guests: 2,
444
+ * });
445
+ * ```
446
+ */
447
+ check(params: AvailabilityCheckParams): Promise<AvailabilityResult>;
448
+ /**
449
+ * Search availability across multiple properties.
450
+ *
451
+ * @param params - Must include `propertyIds`, `checkIn`, `checkOut`; supports filtering and pagination
452
+ *
453
+ * @example
454
+ * ```typescript
455
+ * const results = await booking.availability.search({
456
+ * propertyIds: ["prop_abc", "prop_def"],
457
+ * checkIn: "2025-06-01",
458
+ * checkOut: "2025-06-05",
459
+ * guests: 2,
460
+ * priceRange: { min: 5000, max: 20000 },
461
+ * });
462
+ * ```
463
+ */
464
+ search(params: AvailabilitySearchParams): Promise<AvailabilitySearchResult>;
465
+ /**
466
+ * Generate a calendar view of daily availability for a property.
467
+ *
468
+ * Client-side helper that calls `check()` internally and transforms the result
469
+ * into a `CalendarDay[]` suitable for calendar UI rendering.
470
+ *
471
+ * @param params - Extends `AvailabilityCheckParams` with optional `months` (default: 1)
472
+ *
473
+ * @example
474
+ * ```typescript
475
+ * const calendar = await booking.availability.getCalendar({
476
+ * propertyId: "prop_abc123",
477
+ * checkIn: "2025-06-01",
478
+ * checkOut: "2025-06-30",
479
+ * });
480
+ * ```
481
+ */
482
+ getCalendar(params: CalendarParams): Promise<CalendarDay[]>;
483
+ /**
484
+ * Get available table reservation time slots for a specific date.
485
+ *
486
+ * Client-side helper for the Tables vertical. Calls `check()` internally
487
+ * with `type: "table"` and reshapes the response into `TimeSlot[]`.
488
+ *
489
+ * @param params - Must include `propertyId` and `date`
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const slots = await booking.availability.getTableSlots({
494
+ * propertyId: "prop_abc123",
495
+ * date: "2025-06-15",
496
+ * guests: 4,
497
+ * });
498
+ * ```
499
+ */
500
+ getTableSlots(params: TableSlotParams): Promise<TimeSlot[]>;
501
+ /**
502
+ * Get available service appointment slots for a specific date.
503
+ *
504
+ * Client-side helper for the Services vertical. Calls `check()` internally
505
+ * with `type: "service"` and reshapes the response into `ServiceTimeSlot[]`.
506
+ *
507
+ * @param params - Must include `propertyId` and `date`
508
+ *
509
+ * @example
510
+ * ```typescript
511
+ * const slots = await booking.availability.getServiceSlots({
512
+ * propertyId: "prop_abc123",
513
+ * date: "2025-06-15",
514
+ * providerId: "staff_001",
515
+ * duration: 60,
516
+ * });
517
+ * ```
518
+ */
519
+ getServiceSlots(params: ServiceSlotParams): Promise<ServiceTimeSlot[]>;
520
+ /**
521
+ * Get aggregated pricing statistics for a property and date range.
522
+ *
523
+ * Client-side helper that calls `check()` internally and computes
524
+ * min/max/average/total pricing from available spaces.
525
+ *
526
+ * @param params - Extends `AvailabilityCheckParams` with optional `currency`
527
+ *
528
+ * @example
529
+ * ```typescript
530
+ * const pricing = await booking.availability.getPricing({
531
+ * propertyId: "prop_abc123",
532
+ * checkIn: "2025-06-01",
533
+ * checkOut: "2025-06-05",
534
+ * });
535
+ * console.log(`From €${pricing.minPrice / 100} to €${pricing.maxPrice / 100}`);
536
+ * ```
537
+ */
538
+ getPricing(params: PricingParams): Promise<PricingResult>;
539
+ }
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
+
116
1013
  /** All supported property types in the v4.0 API */
117
1014
  type PropertyType = "hotel" | "resort" | "villa" | "apartment" | "hostel" | "bnb" | "restaurant" | "cafe" | "bar" | "beach" | "spa" | "salon" | "custom";
118
1015
  /** Property lifecycle status */
@@ -225,29 +1122,6 @@ interface ListCategoriesParams {
225
1122
  limit?: number;
226
1123
  }
227
1124
 
228
- /**
229
- * Abstract base class for all SDK services.
230
- * Provides typed HTTP helper methods and path construction.
231
- * Not exported from the public API.
232
- */
233
- declare abstract class BaseService {
234
- protected readonly http: HttpClient;
235
- protected abstract readonly basePath: string;
236
- constructor(http: HttpClient);
237
- /** Build a full path from the base path and additional segments */
238
- protected _buildPath(...segments: string[]): string;
239
- /** GET request returning typed response */
240
- protected _get<T>(path: string, query?: Record<string, string | number | boolean | null | undefined>): Promise<T>;
241
- /** POST request with body, returning typed response */
242
- protected _post<T>(path: string, body: unknown): Promise<T>;
243
- /** PATCH request with body, returning typed response */
244
- protected _patch<T>(path: string, body: unknown): Promise<T>;
245
- /** DELETE request, returning void */
246
- protected _delete(path: string): Promise<void>;
247
- /** GET list request with optional query params, returning paginated response */
248
- protected _list<T>(params?: any): Promise<Paginated<T>>;
249
- }
250
-
251
1125
  /**
252
1126
  * Service for managing space categories (room types) in the Atzentis Booking API.
253
1127
  *
@@ -402,75 +1276,6 @@ declare class PropertiesService extends BaseService {
402
1276
  delete(propertyId: string): Promise<void>;
403
1277
  }
404
1278
 
405
- /**
406
- * All supported space types in the v4.0 API.
407
- *
408
- * Grouped by vertical:
409
- * - **Stays:** `room`, `sunbed`, `parking`
410
- * - **Tables:** `table`, `locker`
411
- * - **Services:** `service`, `meeting_room`, `desk`
412
- * - **Universal:** `custom`
413
- */
414
- type SpaceType = "room" | "table" | "sunbed" | "parking" | "desk" | "meeting_room" | "locker" | "service" | "custom";
415
- /** All 9 space types as a readonly tuple for runtime enumeration */
416
- declare const SPACE_TYPES: readonly ["room", "table", "sunbed", "parking", "desk", "meeting_room", "locker", "service", "custom"];
417
- /** Space availability/lifecycle status */
418
- type SpaceStatus = "available" | "occupied" | "maintenance" | "blocked" | "inactive";
419
- /** All 5 space statuses as a readonly tuple for runtime enumeration */
420
- declare const SPACE_STATUSES: readonly ["available", "occupied", "maintenance", "blocked", "inactive"];
421
- /** A bookable space in the Atzentis Booking system */
422
- interface Space {
423
- id: string;
424
- propertyId: string;
425
- categoryId: string | null;
426
- name: string;
427
- type: SpaceType;
428
- status: SpaceStatus;
429
- /** Used for rooms (hotel floor) and desks/meeting rooms (office floor). Use string to support labels like "B1", "G", "1", "2". */
430
- floor: string | null;
431
- /** Used for tables (cover count) and meeting rooms (person count). Null if not applicable. */
432
- capacity: number | null;
433
- /** POS table reference; set via `linkPosTable()`. Tables vertical only. Null until linked. */
434
- posTableId: string | null;
435
- /** Open bag for vertical-specific extras not covered by standard fields. Schema is consumer-defined. */
436
- metadata: Record<string, unknown> | null;
437
- createdAt: string;
438
- updatedAt: string;
439
- }
440
- /** Input for creating a new space */
441
- interface CreateSpaceInput {
442
- propertyId: string;
443
- name: string;
444
- type: SpaceType;
445
- categoryId?: string;
446
- /** Optional. See `Space.floor` for usage by vertical. */
447
- floor?: string;
448
- /** Optional. See `Space.capacity` for usage by vertical. */
449
- capacity?: number;
450
- /** Optional. See `Space.metadata` for usage by vertical. */
451
- metadata?: Record<string, unknown>;
452
- }
453
- /** Input for updating an existing space — all fields optional */
454
- type UpdateSpaceInput = Partial<Omit<CreateSpaceInput, "propertyId">>;
455
- /** Input for bulk updating spaces — requires `id` to identify each space */
456
- type BulkUpdateSpaceInput = UpdateSpaceInput & {
457
- id: string;
458
- };
459
- /** Input for linking a space to a POS table */
460
- interface LinkPosTableInput {
461
- posTableId: string;
462
- }
463
- /** Query parameters for listing spaces — propertyId is required */
464
- interface ListSpacesParams {
465
- propertyId: string;
466
- type?: SpaceType;
467
- status?: SpaceStatus;
468
- categoryId?: string;
469
- floor?: number | string;
470
- limit?: number;
471
- cursor?: string;
472
- }
473
-
474
1279
  /**
475
1280
  * Service for managing bookable spaces in the Atzentis Booking API.
476
1281
  *
@@ -611,10 +1416,16 @@ declare class SpacesService extends BaseService {
611
1416
  */
612
1417
  declare class BookingClient {
613
1418
  readonly httpClient: HttpClient;
1419
+ private _availability?;
1420
+ private _bookings?;
614
1421
  private _properties?;
615
1422
  private _categories?;
616
1423
  private _spaces?;
617
1424
  constructor(config: BookingClientConfig);
1425
+ /** Availability service — lazy-initialized on first access */
1426
+ get availability(): AvailabilityService;
1427
+ /** Bookings service — lazy-initialized on first access */
1428
+ get bookings(): BookingsService;
618
1429
  /** Properties service — lazy-initialized on first access */
619
1430
  get properties(): PropertiesService;
620
1431
  /** Categories service — lazy-initialized on first access */
@@ -703,4 +1514,4 @@ declare function firstPage<T>(fetcher: PageFetcher<T>, options?: PaginationOptio
703
1514
 
704
1515
  declare const VERSION = "0.1.0";
705
1516
 
706
- export { AuthenticationError, BookingClient, type BookingClientConfig, BookingError, type BookingErrorOptions, type BulkUpdateSpaceInput, 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, 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 Space, type SpaceCategory, type SpaceStatus, type SpaceType, SpacesService, 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 };