@zimmerstack/connect 0.4.1 → 0.6.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,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.4.1";
2
+ export declare const SDK_VERSION = "0.6.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";
@@ -27,19 +27,19 @@ export declare const LIMITS: {
27
27
  readonly maxNightsPerBooking: 90;
28
28
  };
29
29
  /** Every stable error code (`error.code`). Messages are for people and may change; branch on these. */
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"];
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", "COMPANY_KEY_REQUIRED", "BILLING_SETUP_REQUIRED", "OWNER_HAS_ACCOUNT", "SANDBOX_LIMIT", "CONFIRMATION_MISMATCH", "PROPERTY_NOT_REMOVABLE", "PROPERTY_BUSY", "PRICE_UNAVAILABLE"];
31
31
  export type ErrorCode = (typeof ERROR_CODES)[number];
32
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. */
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"];
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", "properties:write"];
34
34
  export type Scope = (typeof SCOPES)[number];
35
35
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
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.";
36
+ export declare const MODIFIER_TAKES_EFFECT = "Saving a modifier makes the channel manager send that channel every date again, so prices already on the channel move to the new rule within minutes.";
37
37
  export interface Error {
38
38
  statuscode: number;
39
39
  /** Human-readable, may change; branch on data.code */
40
40
  message: string;
41
41
  data: {
42
- code: "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";
42
+ code: "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" | "COMPANY_KEY_REQUIRED" | "BILLING_SETUP_REQUIRED" | "OWNER_HAS_ACCOUNT" | "SANDBOX_LIMIT" | "CONFIRMATION_MISMATCH" | "PROPERTY_NOT_REMOVABLE" | "PROPERTY_BUSY" | "PRICE_UNAVAILABLE";
43
43
  details?: unknown;
44
44
  };
45
45
  }
@@ -161,6 +161,97 @@ export interface Properties {
161
161
  sandbox: boolean;
162
162
  }>;
163
163
  }
164
+ export interface PropertyCreate {
165
+ /** The hotel's name, as its guests know it */
166
+ name: string;
167
+ /** The person who owns the hotel's account */
168
+ owner: {
169
+ name: string;
170
+ /** The owner's own address. The sign-in details are sent here, never to you */
171
+ email: string;
172
+ /** Digits, with an optional + and spaces, dots, dashes or brackets */
173
+ phone: string;
174
+ };
175
+ address: {
176
+ line1: string;
177
+ city: string;
178
+ state?: string;
179
+ postalCode?: string;
180
+ /** ISO 3166-1 alpha-2, for example IN, LK, PT */
181
+ country: string;
182
+ };
183
+ /** ISO 4217: what the hotel sells in. Default: the country's own currency. A hotel in India sells in INR */
184
+ currency?: string;
185
+ /** An IANA zone of the hotel's country. Default: the country's main zone */
186
+ timezone?: string;
187
+ /** India only: the hotel's GSTIN when it is registered under GST. Leave it out when it is not, and for a hotel in any other country */
188
+ taxId?: string;
189
+ /** At least one. Each is born with one room-only rate plan at its defaultRate */
190
+ roomTypes: Array<{
191
+ /** Your own id for this room type. Send the same ref to PUT /catalog/room-types later and it updates this one instead of making a second */
192
+ ref?: string;
193
+ /** Shown to the owner and sent to the channel manager as the title; each name once per request */
194
+ name: string;
195
+ /** Sellable rooms of this type */
196
+ roomCount: number;
197
+ /** Most adults one room takes; default 2 */
198
+ adults?: number;
199
+ /** The nightly price new dates open at, in MAJOR units of the hotel's currency (e.g. 4500 or "4500.00") */
200
+ defaultRate: number | string;
201
+ }>;
202
+ }
203
+ export interface PropertyCreated {
204
+ /** The id your company key names in the X-ZS-Property header from now on */
205
+ id: number;
206
+ /** As stored. A sandbox's name ends in (sandbox) and is at most 60 characters */
207
+ name: string;
208
+ timezone: string;
209
+ currency: string;
210
+ /** The property publishes to its channels. false for a new hotel until your first PUT /catalog/room-types puts it on the channel manager; always true for a sandbox */
211
+ channelManager: boolean;
212
+ /** true when a test key made it: everything lands locally, nothing reaches a channel and nothing is billed */
213
+ sandbox: boolean;
214
+ billing: {
215
+ /** ACTIVE: its billing has started, it is on your next monthly invoice · WAITING: the hotel is live, its billing has not started yet · NOT_BILLED: a sandbox */
216
+ state: "ACTIVE" | "WAITING" | "NOT_BILLED";
217
+ /** Why billing waits; null otherwise. SETUP: your billing setup is not complete · OVERDUE: one of your invoices is overdue · UNPAID_LIMIT: you have added as many hotels as you may before your first paid invoice · REVIEW: ZimmerStack starts it */
218
+ reason: "SETUP" | "OVERDUE" | "UNPAID_LIMIT" | "REVIEW" | null;
219
+ /** The same in one sentence, with what to do next; may change, branch on state and reason */
220
+ message: string;
221
+ };
222
+ /** true: an earlier request with this X-Idempotency-Key already added this hotel; nothing new was made */
223
+ replay: boolean;
224
+ }
225
+ export interface PropertyRemoved {
226
+ id: number;
227
+ /** The hotel's name; null only for a sandbox removed before its name was recorded */
228
+ name: string | null;
229
+ removed: true;
230
+ /** true: it was already removed before this request; the rest of the answer is where it stands now */
231
+ replay: boolean;
232
+ sandbox: boolean;
233
+ /** Nobody signs in to the hotel's account any more and no key reaches it */
234
+ access: "CLOSED";
235
+ billing: {
236
+ /** CANCELLED: the hotel's subscription is cancelled · NOT_BILLED: a sandbox, never billed */
237
+ state: "CANCELLED" | "NOT_BILLED";
238
+ /** ISO 8601 instant the subscription was cancelled; null for a sandbox */
239
+ cancelledAt: string | null;
240
+ };
241
+ channelManager: {
242
+ /** REMOVED: its channel connections, rate plans, room types and listing are gone from the channel manager · RETRYING: a step is still pending; ZimmerStack retries it and nothing is needed from you · NOT_CONNECTED: it was never on the channel manager */
243
+ state: "REMOVED" | "RETRYING" | "NOT_CONNECTED";
244
+ /** While RETRYING, the step that is pending, in the order they run: the channel connections, then the rate plans, then the room types, then the property. null otherwise, and on a replay */
245
+ step: "CHANNELS" | "RATE_PLANS" | "ROOM_TYPES" | "PROPERTY" | null;
246
+ /** While RETRYING, what was still on the channel manager when this request ended; null otherwise, and on a replay */
247
+ stillConnected: {
248
+ channels: number;
249
+ ratePlans: number | null;
250
+ roomTypes: number | null;
251
+ property: boolean;
252
+ } | null;
253
+ };
254
+ }
164
255
  export interface RoomTypesUpsert {
165
256
  /** Each ref once per request */
166
257
  roomTypes: Array<{
@@ -675,7 +766,7 @@ export interface ModifierResult {
675
766
  }>;
676
767
  /** false when the channel already held exactly these steps: nothing was sent to the channel manager and nothing was counted */
677
768
  changed: boolean;
678
- /** When it takes effect. Always: "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." */
769
+ /** When it takes effect. Always: "Saving a modifier makes the channel manager send that channel every date again, so prices already on the channel move to the new rule within minutes." */
679
770
  notice: string;
680
771
  }
681
772
  export interface RatesResendAccepted {
@@ -1013,6 +1104,24 @@ export interface Operations {
1013
1104
  body: undefined;
1014
1105
  response: Properties;
1015
1106
  };
1107
+ /** Add a hotel (a software partner's company key) */
1108
+ "POST /properties": {
1109
+ path: undefined;
1110
+ query: undefined;
1111
+ body: PropertyCreate;
1112
+ response: PropertyCreated;
1113
+ };
1114
+ /** Remove a hotel you added (a software partner's company key) */
1115
+ "DELETE /properties/{propertyId}": {
1116
+ path: {
1117
+ propertyId: string | number;
1118
+ };
1119
+ query: {
1120
+ confirm: string;
1121
+ };
1122
+ body: undefined;
1123
+ response: PropertyRemoved;
1124
+ };
1016
1125
  /** The property this key is for */
1017
1126
  "GET /property": {
1018
1127
  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.4.1";
4
+ export const SDK_VERSION = "0.6.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";
@@ -86,7 +86,15 @@ export const ERROR_CODES = [
86
86
  "RATE_OUT_OF_BAND",
87
87
  "CHANNEL_NOT_FOUND",
88
88
  "CHANNEL_SHARED",
89
- "MODIFIER_OUT_OF_BAND"
89
+ "MODIFIER_OUT_OF_BAND",
90
+ "COMPANY_KEY_REQUIRED",
91
+ "BILLING_SETUP_REQUIRED",
92
+ "OWNER_HAS_ACCOUNT",
93
+ "SANDBOX_LIMIT",
94
+ "CONFIRMATION_MISMATCH",
95
+ "PROPERTY_NOT_REMOVABLE",
96
+ "PROPERTY_BUSY",
97
+ "PRICE_UNAVAILABLE"
90
98
  ];
91
99
  /** What a key may do. The hotel's owner (or, for a vendor's key, the vendor) chose them when the key was made. */
92
100
  export const SCOPES = [
@@ -99,13 +107,16 @@ export const SCOPES = [
99
107
  "direct-bookings:cancel",
100
108
  "bookings:read",
101
109
  "bookings:write",
102
- "bookings:payments"
110
+ "bookings:payments",
111
+ "properties:write"
103
112
  ];
104
113
  /** When a channel's price modifier takes effect. Show it where a person saves one. */
105
- export 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.";
114
+ export const MODIFIER_TAKES_EFFECT = "Saving a modifier makes the channel manager send that channel every date again, so prices already on the channel move to the new rule within minutes.";
106
115
  /** idempotent: the server replays the stored answer when the idempotency key repeats, so the client may resend the request after a network failure. */
107
116
  export const OPERATIONS = {
108
117
  "GET /properties": { idempotent: false, bodyRequired: false },
118
+ "POST /properties": { idempotent: true, bodyRequired: true },
119
+ "DELETE /properties/{propertyId}": { idempotent: false, bodyRequired: false },
109
120
  "GET /property": { idempotent: false, bodyRequired: false },
110
121
  "GET /catalog": { idempotent: false, bodyRequired: false },
111
122
  "PUT /catalog/room-types": { idempotent: true, bodyRequired: true },
@@ -5,7 +5,7 @@
5
5
  * mobile app, a repository or a log line.
6
6
  */
7
7
  export { ZimmerStack } from "./client.js";
8
- export type { ClientEvent, ReadOptions, RequestArgs, WriteOptions, ZimmerStackOptions } from "./client.js";
8
+ export type { ClientEvent, RatePlanInput, ReadOptions, RequestArgs, RoomTypeInput, StructureSaved, WriteOptions, ZimmerStackOptions } from "./client.js";
9
9
  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";
@@ -6,6 +6,8 @@ export interface ReferenceOperation {
6
6
  description: string;
7
7
  scope: string | null;
8
8
  call: string;
9
+ /** The client's other names for the same operation. */
10
+ also: string[];
9
11
  path: string[];
10
12
  query: Array<{
11
13
  name: string;