@zimmerstack/connect 0.2.0 → 0.4.0

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.
@@ -1,7 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZimmerStackWebhookError = void 0;
3
+ exports.ZimmerStackWebhookError = exports.BOOKING_EVENT_TYPES = exports.WEBSITE_BOOKING_EVENT_TYPES = exports.OTA_BOOKING_EVENT_TYPES = void 0;
4
+ exports.isWebsiteBookingEvent = isWebsiteBookingEvent;
5
+ exports.isOtaBookingEvent = isOtaBookingEvent;
4
6
  exports.verifyWebhook = verifyWebhook;
7
+ /**
8
+ * Verifying a webhook ZimmerStack sent you (Standard Webhooks: the `webhook-id`, `webhook-timestamp` and
9
+ * `webhook-signature` headers). Uses Web Crypto, so it runs on Node and on edge runtimes alike.
10
+ */
11
+ /** An OTA booking arrived, changed or was cancelled (through the channel manager). */
12
+ exports.OTA_BOOKING_EVENT_TYPES = ["channel.booking.created", "channel.booking.modified", "channel.booking.cancelled"];
13
+ /**
14
+ * A guest booked, or cancelled, on the hotel's own website through ZimmerStack's booking engine. The same
15
+ * booking object as the OTA events, in a family of its own: an endpoint receives these only when it lists
16
+ * the two types. There is no modified event.
17
+ */
18
+ exports.WEBSITE_BOOKING_EVENT_TYPES = ["direct.booking.created", "direct.booking.cancelled"];
19
+ /** Every event whose `data.booking` is a booking, of either family. */
20
+ exports.BOOKING_EVENT_TYPES = [...exports.OTA_BOOKING_EVENT_TYPES, ...exports.WEBSITE_BOOKING_EVENT_TYPES];
21
+ const isType = (list, event) => typeof event?.type === "string" && list.includes(event.type);
22
+ /**
23
+ * True for `direct.booking.created` and `direct.booking.cancelled`: a booking made on the hotel's own
24
+ * website. A PMS that pushes room counts must put it in its own calendar before its next push.
25
+ */
26
+ function isWebsiteBookingEvent(event) {
27
+ return isType(exports.WEBSITE_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
28
+ }
29
+ /** True for `channel.booking.created`, `.modified` and `.cancelled`: a booking an OTA sent. */
30
+ function isOtaBookingEvent(event) {
31
+ return isType(exports.OTA_BOOKING_EVENT_TYPES, event) && Boolean(event.data?.booking);
32
+ }
5
33
  class ZimmerStackWebhookError extends Error {
6
34
  /** Why the delivery was refused. Answer 400 and do not act on the body. */
7
35
  reason;
@@ -1,4 +1,4 @@
1
- import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
1
+ import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type DirectBookingCancel, type DirectBookingCancelResult, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
2
2
  import { type Grid, type GridEdits, type ModifierStep } from "./grid.js";
3
3
  export interface ZimmerStackOptions {
4
4
  /**
@@ -231,10 +231,52 @@ export declare class ZimmerStack {
231
231
  */
232
232
  all: (query?: Omit<NonNullable<Op<"GET /channel-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
233
233
  };
234
+ readonly directBookings: {
235
+ /**
236
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
237
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
238
+ */
239
+ list: (query?: Op<"GET /direct-bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").ChannelBookingsList>;
240
+ get: (bookingId: number, options?: ReadOptions) => Promise<ChannelBooking>;
241
+ /**
242
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
243
+ * before a full push, so the sold rooms are in its own calendar first.
244
+ *
245
+ * @example
246
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
247
+ */
248
+ all: (query?: Omit<NonNullable<Op<"GET /direct-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
249
+ /**
250
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
251
+ * `direct-bookings:cancel`, granted on its own and never by default.
252
+ *
253
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
254
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
255
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
256
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
257
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
258
+ *
259
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
260
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
261
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
262
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
263
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
264
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
265
+ * when a retry may come from another process.
266
+ *
267
+ * @example
268
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
269
+ */
270
+ cancel: (bookingId: number, body?: DirectBookingCancel, options?: WriteOptions) => Promise<DirectBookingCancelResult>;
271
+ };
234
272
  readonly sandbox: {
235
273
  bookings: {
236
274
  list: (options?: ReadOptions) => Promise<import("./generated.js").SandboxBookingsList>;
237
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
275
+ /**
276
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
277
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
278
+ * is `direct.booking.created`.
279
+ */
238
280
  create: (body: SandboxBookingCreate, options?: WriteOptions) => Promise<import("./generated.js").SandboxBooking>;
239
281
  cancel: (bookingId: number, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
240
282
  modify: (bookingId: number, body: SandboxBookingModify, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
@@ -546,12 +546,52 @@ export class ZimmerStack {
546
546
  * @example
547
547
  * for await (const booking of zs.channelBookings.all({ since: lastSeen })) save(booking);
548
548
  */
549
- all: (query, options) => this.#allChannelBookings(query, options),
549
+ all: (query, options) => this.#allPages((cursor) => this.channelBookings.list({ limit: 100, ...query, cursor }, options)),
550
550
  };
551
- async *#allChannelBookings(query, options) {
551
+ /* ── bookings guests made on the hotel's own website (our booking engine) ── */
552
+ directBookings = {
553
+ /**
554
+ * Website bookings, in the webhook's shape (`direct.booking.*`), cancellations included. Scope
555
+ * `direct-bookings:read`. Follow `nextCursor`, or use `all`.
556
+ */
557
+ list: (query, options) => this.request("GET /direct-bookings", { query, ...options }),
558
+ get: (bookingId, options) => this.request("GET /direct-bookings/{bookingId}", { path: { bookingId }, ...options }),
559
+ /**
560
+ * Every website booking changed since `since`, page by page. A PMS that pushes room counts reads this
561
+ * before a full push, so the sold rooms are in its own calendar first.
562
+ *
563
+ * @example
564
+ * for await (const booking of zs.directBookings.all({ since: lastSeen })) applyToMyCalendar(booking);
565
+ */
566
+ all: (query, options) => this.#allPages((cursor) => this.directBookings.list({ limit: 100, ...query, cursor }, options)),
567
+ /**
568
+ * Cancel a whole website booking that is still UPCOMING, and say what the guest gets back. Scope
569
+ * `direct-bookings:cancel`, granted on its own and never by default.
570
+ *
571
+ * `refund`: `"policy"` (the default) is what the booking's own cancellation policy gives back now, as
572
+ * if the guest cancelled on the booking page; `"full"` is everything the guest paid online (the hotel
573
+ * is at fault: an overbooking); `"none"` moves no money (the hotel settles it another way). The refund
574
+ * goes back to the guest's online payment and never exceeds it. The answer's `refund` says how much
575
+ * and where it stands (NONE, PENDING, PROCESSED, MANUAL).
576
+ *
577
+ * IT MOVES A GUEST'S MONEY. Call it from a person's own cancel button, with the refund they chose;
578
+ * never from a loop, a sync job or a test against a live key. A booking already cancelled answers
579
+ * `replay: true` and moves no money; checked in, checked out or a no-show is BOOKING_NOT_CANCELLABLE.
580
+ * Your own cancel comes back as `direct.booking.cancelled` ("Cancelled by the hotel"): treat it as
581
+ * already applied. The call carries an idempotency key (yours, or one the client makes) and a retry
582
+ * after a network failure reuses it, so a cancel never lands twice; pass your own `idempotencyKey`
583
+ * when a retry may come from another process.
584
+ *
585
+ * @example
586
+ * const { refund } = await zs.directBookings.cancel(bookingId, { refund: "full", reason: "Overbooked" });
587
+ */
588
+ cancel: (bookingId, body = {}, options) => this.request("POST /direct-bookings/{bookingId}/cancel", { path: { bookingId }, body, ...options }),
589
+ };
590
+ /** Follow a booking list's `nextCursor` to its last page. */
591
+ async *#allPages(read) {
552
592
  let cursor;
553
593
  do {
554
- const page = await this.channelBookings.list({ limit: 100, ...query, cursor }, options);
594
+ const page = await read(cursor);
555
595
  yield* page.items;
556
596
  cursor = page.nextCursor ?? undefined;
557
597
  } while (cursor);
@@ -560,7 +600,11 @@ export class ZimmerStack {
560
600
  sandbox = {
561
601
  bookings: {
562
602
  list: (options) => this.request("GET /sandbox/bookings", options),
563
- /** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
603
+ /**
604
+ * Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint.
605
+ * With `otaName: "Website"` it pretends a guest booked on the hotel's own website instead, and the webhook
606
+ * is `direct.booking.created`.
607
+ */
564
608
  create: (body, options) => this.request("POST /sandbox/bookings", { body, ...options }),
565
609
  cancel: (bookingId, options) => this.request("POST /sandbox/bookings/{bookingId}/cancel", { path: { bookingId }, ...options }),
566
610
  modify: (bookingId, body, options) => this.request("POST /sandbox/bookings/{bookingId}/modify", { path: { bookingId }, body, ...options }),
@@ -1,5 +1,5 @@
1
1
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
2
- export declare const SDK_VERSION = "0.2.0";
2
+ export declare const SDK_VERSION = "0.4.0";
3
3
  /** Where the API lives. The key is sent nowhere else. */
4
4
  export declare const API_ORIGIN = "https://api.zimmerstack.com";
5
5
  export declare const API_PREFIX = "/api/v1/connect-api/v1";
@@ -21,6 +21,8 @@ export declare const LIMITS: {
21
21
  readonly bookingsPerMinute: 20;
22
22
  readonly propertyBookingsPerMinute: 40;
23
23
  readonly propertyBookingsPerDay: 500;
24
+ readonly directCancelsPerMinute: 10;
25
+ readonly propertyDirectCancelsPerDay: 50;
24
26
  readonly companyRequestsPerMinute: 1200;
25
27
  readonly maxNightsPerBooking: 90;
26
28
  };
@@ -28,7 +30,7 @@ export declare const LIMITS: {
28
30
  export declare const ERROR_CODES: readonly ["API_KEY_INVALID", "API_KEY_REVOKED", "API_KEY_EXPIRED", "CONNECT_API_NOT_CONFIGURED", "IP_NOT_ALLOWED", "SCOPE_MISSING", "PROPERTY_UNAVAILABLE", "CHANNEL_MANAGER_DISABLED", "PMS_NOT_AVAILABLE", "VALIDATION", "RANGE_INVALID", "HORIZON", "TOO_MANY_UPDATES", "TOO_MANY_CELLS", "UNKNOWN_ROOM_TYPE", "UNKNOWN_RATE_PLAN", "CURRENCY_MISMATCH", "RATE_LIMITED", "NOTHING_ACCEPTED", "BATCH_NOT_FOUND", "IDEMPOTENCY_KEY_INVALID", "IDEMPOTENCY_KEY_REUSED", "IDEMPOTENCY_IN_FLIGHT", "STAY_INVALID", "UNKNOWN_ROOM_TYPE_FOR_PLAN", "OCCUPANCY_EXCEEDED", "NO_AVAILABILITY", "EXTERNAL_REFERENCE_REUSED", "PAYMENT_NOT_ALLOWED", "PAYMENT_EXCEEDS_TOTAL", "BOOKING_NOT_FOUND", "BOOKING_NOT_CANCELLABLE", "MODULE_NOT_ENTITLED", "SANDBOX_ONLY", "ROOM_TYPE_NOT_FOUND", "RATE_PLAN_NOT_FOUND", "CATALOG_CONFLICT", "CATALOG_BUSY", "CHANNEL_MANAGER_ERROR", "PROPERTY_REQUIRED", "PROPERTY_NOT_FOUND", "ARI_NOT_AUTHORITATIVE", "ROUTE_NOT_FOUND", "PAYLOAD_TOO_LARGE", "AUTH_BACKEND_UNAVAILABLE", "BOOKING_NOT_MODIFIABLE", "SANDBOX_NOT_FOUND", "SANDBOX_INCOMPLETE", "WRITES_FROZEN", "WRITES_SUSPENDED", "SHIELD_UNAVAILABLE", "CATALOG_LIMIT_REACHED", "TOO_MANY_NEW_ENTITIES", "RATE_OUT_OF_BAND", "CHANNEL_NOT_FOUND", "CHANNEL_SHARED", "MODIFIER_OUT_OF_BAND"];
29
31
  export type ErrorCode = (typeof ERROR_CODES)[number];
30
32
  /** What a key may do. The hotel's owner (or, for a vendor's key, the vendor) chose them when the key was made. */
31
- export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "bookings:read", "bookings:write", "bookings:payments"];
33
+ export declare const SCOPES: readonly ["ari:read", "ari:write", "catalog:write", "channel-modifiers:write", "channel-bookings:read", "direct-bookings:read", "direct-bookings:cancel", "bookings:read", "bookings:write", "bookings:payments"];
32
34
  export type Scope = (typeof SCOPES)[number];
33
35
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
34
36
  export declare const MODIFIER_TAKES_EFFECT = "A modifier applies to prices sent to the channel after the change. Prices already on the channel stay as they are until those nights are sent again.";
@@ -585,9 +587,9 @@ export interface SandboxBookingCreate {
585
587
  adults?: number;
586
588
  /** The guest's name; default a fictional one */
587
589
  guestName?: string;
588
- /** The channel the booking pretends to arrive from; default Booking.com */
589
- otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo";
590
- /** true = the channel collected the money, so totalPaid equals the total; default false (pay at the property) */
590
+ /** The channel the booking pretends to arrive from; default Booking.com. "Website" simulates a booking on the hotel's own website (our booking engine): it sends direct.booking.created and is listed by GET /direct-bookings, not GET /channel-bookings */
591
+ otaName?: "Booking.com" | "Expedia" | "Agoda" | "Airbnb" | "MakeMyTrip" | "Goibibo" | "Website";
592
+ /** true = the channel collected the money (for Website: the guest paid online), so totalPaid equals the total; default false (pay at the property) */
591
593
  paidByOta?: boolean;
592
594
  }
593
595
  export interface SandboxBookingModify {
@@ -846,6 +848,96 @@ export interface ChannelBooking {
846
848
  createdAt: string;
847
849
  updatedAt: string;
848
850
  }
851
+ export interface DirectBookingCancel {
852
+ /** policy (the default): what the booking's own cancellation policy gives back now, the same as the guest cancelling on the booking page. full: everything the guest paid online. none: nothing; the hotel settles any money itself. */
853
+ refund?: "policy" | "full" | "none";
854
+ /** Why; kept on the booking's activity log in ZimmerStack */
855
+ reason?: string;
856
+ }
857
+ export interface DirectBookingCancelResult {
858
+ /** The booking after the cancel, the webhook's shape: status CANCELLED, every room CANCELLED */
859
+ booking: {
860
+ id: number;
861
+ reference: string;
862
+ status: "CONFIRMED" | "CANCELLED";
863
+ stayStatus: string;
864
+ channel: {
865
+ otaName: string;
866
+ otaReservationCode: string;
867
+ source: string;
868
+ sourceGroup: string;
869
+ };
870
+ stay: {
871
+ checkIn: string;
872
+ checkOut: string;
873
+ nights: number;
874
+ dayUse: boolean;
875
+ };
876
+ guest: {
877
+ fullName: string;
878
+ firstName: string | null;
879
+ lastName: string | null;
880
+ phone?: string | null;
881
+ email?: string | null;
882
+ country: string | null;
883
+ language: string | null;
884
+ };
885
+ guestNotes: string | null;
886
+ occupancy: {
887
+ adults: number;
888
+ children: number;
889
+ };
890
+ rooms: Array<{
891
+ roomTypeId: number;
892
+ roomTypeName: string;
893
+ ratePlanId?: number | null;
894
+ mealPlan: "EP" | "CP" | "MAP" | "AP";
895
+ adults: number;
896
+ children: number;
897
+ checkIn: string;
898
+ checkOut: string;
899
+ nights: number;
900
+ dayUse: boolean;
901
+ ratePerNight: number;
902
+ amount: number;
903
+ status: string;
904
+ }>;
905
+ amounts: {
906
+ currency: string;
907
+ total: number;
908
+ paid: number;
909
+ balanceDue: number;
910
+ paymentCollect: "ota" | "property" | "unknown";
911
+ };
912
+ finance: {
913
+ otaName: string;
914
+ amountBasis: string;
915
+ currency: string | null;
916
+ grossAmount: number | null;
917
+ commissionAmount: number | null;
918
+ taxAmount: number | null;
919
+ netPayoutAmount: number | null;
920
+ } | null;
921
+ cancellation: {
922
+ at: string;
923
+ reason: string | null;
924
+ } | null;
925
+ createdAt: string;
926
+ updatedAt: string;
927
+ };
928
+ refund: {
929
+ /** The refund this call asked for; null on a replay */
930
+ requested: "policy" | "full" | "none" | null;
931
+ /** What the guest gets back, in currency's major units (1998.5 = ₹1,998.50); 0 when nothing is owed */
932
+ amount: number;
933
+ /** ISO 4217, the property's currency */
934
+ currency: string;
935
+ /** NONE: nothing owed. PROCESSED: the payment gateway accepted the refund. PENDING: the refund is recorded and on its way (the gateway is processing it, or ZimmerStack issues it by hand). MANUAL: money is owed but there is no online payment to refund against; the hotel settles it. */
936
+ status: "NONE" | "PENDING" | "PROCESSED" | "MANUAL";
937
+ };
938
+ /** true: the booking was already cancelled; nothing changed and no money moved */
939
+ replay: boolean;
940
+ }
849
941
  export interface SandboxBooking {
850
942
  /** The PMS booking id, the one the webhook carries */
851
943
  bookingId: number;
@@ -854,6 +946,7 @@ export interface SandboxBooking {
854
946
  /** The pretend channel-side id */
855
947
  channelBookingId: string;
856
948
  otaName: string;
949
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
857
950
  status: "UPCOMING" | "CANCELLED";
858
951
  guestName: string;
859
952
  checkIn: string;
@@ -861,9 +954,9 @@ export interface SandboxBooking {
861
954
  nights: number;
862
955
  rooms: number;
863
956
  roomTypeId: number;
864
- /** Major units, per room per night */
957
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
865
958
  nightlyRate: number;
866
- /** Major units */
959
+ /** Major units: every night's price × rooms */
867
960
  total: number;
868
961
  currency: string;
869
962
  paidByOta: boolean;
@@ -872,13 +965,13 @@ export interface SandboxBooking {
872
965
  createdAt: string;
873
966
  /** What this call put on the wire for the sandbox's webhook endpoints */
874
967
  webhook: {
875
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
968
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
876
969
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
877
970
  queued: boolean;
878
971
  };
879
972
  }
880
973
  export interface SandboxBookingsList {
881
- /** Simulated OTA bookings on the sandbox, newest first */
974
+ /** Simulated bookings on the sandbox (OTA and website), newest first */
882
975
  bookings: Array<{
883
976
  /** The PMS booking id, the one the webhook carries */
884
977
  bookingId: number;
@@ -887,6 +980,7 @@ export interface SandboxBookingsList {
887
980
  /** The pretend channel-side id */
888
981
  channelBookingId: string;
889
982
  otaName: string;
983
+ /** The stay's state. GET /channel-bookings reads the same booking as status CONFIRMED (or CANCELLED) with stayStatus UPCOMING */
890
984
  status: "UPCOMING" | "CANCELLED";
891
985
  guestName: string;
892
986
  checkIn: string;
@@ -894,9 +988,9 @@ export interface SandboxBookingsList {
894
988
  nights: number;
895
989
  rooms: number;
896
990
  roomTypeId: number;
897
- /** Major units, per room per night */
991
+ /** Major units, per room per night: the average when the nights differ. Each night is priced from the sandbox's own record, what GET /rates gives for the room type's first rate plan */
898
992
  nightlyRate: number;
899
- /** Major units */
993
+ /** Major units: every night's price × rooms */
900
994
  total: number;
901
995
  currency: string;
902
996
  paidByOta: boolean;
@@ -905,7 +999,7 @@ export interface SandboxBookingsList {
905
999
  createdAt: string;
906
1000
  /** What this call put on the wire for the sandbox's webhook endpoints */
907
1001
  webhook: {
908
- eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled";
1002
+ eventType: "channel.booking.created" | "channel.booking.modified" | "channel.booking.cancelled" | "direct.booking.created" | "direct.booking.cancelled";
909
1003
  /** The event is in the outbox; every active endpoint on the sandbox receives it within seconds */
910
1004
  queued: boolean;
911
1005
  };
@@ -1103,6 +1197,36 @@ export interface Operations {
1103
1197
  body: undefined;
1104
1198
  response: ChannelBooking;
1105
1199
  };
1200
+ /** The bookings guests made on the hotel's own website, in the webhook's shape */
1201
+ "GET /direct-bookings": {
1202
+ path: undefined;
1203
+ query: {
1204
+ since?: string;
1205
+ status?: "CONFIRMED" | "CANCELLED";
1206
+ limit?: number;
1207
+ cursor?: string;
1208
+ };
1209
+ body: undefined;
1210
+ response: ChannelBookingsList;
1211
+ };
1212
+ /** One website booking, the webhook's shape */
1213
+ "GET /direct-bookings/{bookingId}": {
1214
+ path: {
1215
+ bookingId: string | number;
1216
+ };
1217
+ query: undefined;
1218
+ body: undefined;
1219
+ response: ChannelBooking;
1220
+ };
1221
+ /** Cancel a website booking and refund it: per its policy, in full, or not at all */
1222
+ "POST /direct-bookings/{bookingId}/cancel": {
1223
+ path: {
1224
+ bookingId: string | number;
1225
+ };
1226
+ query: undefined;
1227
+ body: DirectBookingCancel;
1228
+ response: DirectBookingCancelResult;
1229
+ };
1106
1230
  /** Simulated OTA bookings on the sandbox, newest first */
1107
1231
  "GET /sandbox/bookings": {
1108
1232
  path: undefined;
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/generate.mjs from the Connect API's public contract (ZimmerStack Connect API v1).
2
2
  // Do not edit: change the contract, then run `pnpm --dir apps/connect-sdk run generate`.
3
3
  /** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
4
- export const SDK_VERSION = "0.2.0";
4
+ export const SDK_VERSION = "0.4.0";
5
5
  /** Where the API lives. The key is sent nowhere else. */
6
6
  export const API_ORIGIN = "https://api.zimmerstack.com";
7
7
  export const API_PREFIX = "/api/v1/connect-api/v1";
@@ -23,6 +23,8 @@ export const LIMITS = {
23
23
  "bookingsPerMinute": 20,
24
24
  "propertyBookingsPerMinute": 40,
25
25
  "propertyBookingsPerDay": 500,
26
+ "directCancelsPerMinute": 10,
27
+ "propertyDirectCancelsPerDay": 50,
26
28
  "companyRequestsPerMinute": 1200,
27
29
  "maxNightsPerBooking": 90
28
30
  };
@@ -93,6 +95,8 @@ export const SCOPES = [
93
95
  "catalog:write",
94
96
  "channel-modifiers:write",
95
97
  "channel-bookings:read",
98
+ "direct-bookings:read",
99
+ "direct-bookings:cancel",
96
100
  "bookings:read",
97
101
  "bookings:write",
98
102
  "bookings:payments"
@@ -124,6 +128,9 @@ export const OPERATIONS = {
124
128
  "POST /rates/resend": { idempotent: true, bodyRequired: false },
125
129
  "GET /channel-bookings": { idempotent: false, bodyRequired: false },
126
130
  "GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
131
+ "GET /direct-bookings": { idempotent: false, bodyRequired: false },
132
+ "GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
133
+ "POST /direct-bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
127
134
  "GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
128
135
  "POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
129
136
  "POST /sandbox/bookings/{bookingId}/cancel": { idempotent: false, bodyRequired: false },
@@ -10,7 +10,7 @@ export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
10
10
  export type { LocalErrorCode } from "./errors.js";
11
11
  export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
12
12
  export type { Grid, GridEdits, ModifierStep, Range, Restrictions } from "./grid.js";
13
- export { verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
- export type { WebhookEvent } from "./webhooks.js";
13
+ export { BOOKING_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
14
+ export type { BookingEvent, BookingEventType, OtaBookingEvent, OtaBookingEventType, WebhookEvent, WebhookEventType, WebsiteBookingEvent, WebsiteBookingEventType } from "./webhooks.js";
15
15
  export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, SCOPES, SDK_VERSION } from "./generated.js";
16
16
  export type * from "./generated.js";
package/dist/esm/index.js CHANGED
@@ -7,5 +7,5 @@
7
7
  export { ZimmerStack } from "./client.js";
8
8
  export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
9
9
  export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
10
- export { verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
10
+ export { BOOKING_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isOtaBookingEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError } from "./webhooks.js";
11
11
  export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, SCOPES, SDK_VERSION } from "./generated.js";