@zimmerstack/connect 0.0.0-stage → 0.2.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.
package/AGENTS.md ADDED
@@ -0,0 +1,107 @@
1
+ # Building on @zimmerstack/connect: rules for coding agents
2
+
3
+ You are writing code that calls the ZimmerStack Connect API through its official package. A write
4
+ through it changes a real hotel's prices and rooms on every booking site it sells on. The package
5
+ enforces most of the API's rules for you; this file is the rest. Keep it in the repository (as
6
+ AGENTS.md or CLAUDE.md) and follow it. The whole API reference, in one file an agent can read:
7
+ https://docs.zimmerstack.com/llms-full.txt
8
+
9
+ ## The key
10
+
11
+ - It lives in the environment variable `ZIMMERSTACK_CONNECT_KEY` on a server. Never write it into a
12
+ file that is committed, a log line, an error message, a URL, a test fixture or anything a browser
13
+ or a mobile app receives. Never print it. `new ZimmerStack()` reads it by itself.
14
+ - The package refuses to start in a browser or in React Native. Do not work around that: the
15
+ person's own frontend calls their own server, and the server calls ZimmerStack. Never put the key in
16
+ a variable a bundler sends to the browser (`VITE_`, `NEXT_PUBLIC_`, `REACT_APP_`, `EXPO_PUBLIC_`).
17
+ An app with no server gets the smallest one: https://docs.zimmerstack.com/sdk#no-server. A plain
18
+ `fetch` from a browser is refused too ("Failed to fetch"), on purpose.
19
+ - `zsk_test_…` is a sandbox: nothing reaches a channel. Build and test with it. `zsk_live_…` is a real
20
+ hotel. The package refuses to WRITE with a live key under a test runner; never switch that off to
21
+ make a test pass.
22
+ - A software vendor's company key acts on one hotel at a time: `zs.forProperty(propertyId)`
23
+ (`zs.properties.list()` names them), or `ZIMMERSTACK_PROPERTY_ID` in the environment for an app that
24
+ serves one hotel. A test company key that reaches one sandbox finds it by itself; with several,
25
+ name one; a live key never guesses.
26
+ - No key yet: a software company signs up, free, at https://www.zimmerstack.com/partners/pms-companies#join
27
+ and makes test keys in the partner portal (Developers); a hotel's owner makes one in Admin →
28
+ Developers → API keys.
29
+
30
+ ## Let the package pace; never work around it
31
+
32
+ - It reads the `RateLimit` header and slows down before a budget runs out, sends writes one at a
33
+ time, retries only what passes with time (429, 5xx, a network failure) under the same idempotency
34
+ key, and gives up with a `ZimmerStackError` otherwise. Do not wrap its calls in your own retry
35
+ loop, and never resend a 4xx other than 429: it is a verdict on the request. Fix the request.
36
+ - Per minute: 120 requests and 30 writes per key; 300 and 60 for all of a hotel's keys together.
37
+ A hotel also has budgets per hour and per day that count CHANGED cells (at least 10,000 an hour, 30,000
38
+ a day). Hitting one is `error.code === "RATE_LIMITED"` with `error.retryAfterSeconds`: tell the
39
+ person when to try again; do not sleep through an hour.
40
+ - One instance per process (`new ZimmerStack()` once, in a module). Two instances do not share a pace.
41
+ - Never write on a timer, in a loop over all nights, or "to be safe". Send what a person changed,
42
+ when they changed it: `zs.grid.save(edits)` folds nights into ranges and splits a large save.
43
+ - Do not poll faster than every 15 seconds (`zs.batches.wait` already does it right), and stop.
44
+
45
+ ## Money and dates
46
+
47
+ - A price is SENT in major units (4500 = 4,500.00 of the hotel's own currency) with that currency, and READ in minor
48
+ units (`rateMinor`). `zs.grid.load` gives major units; `zs.grid.save` takes them.
49
+ - A date is a plain `YYYY-MM-DD` calendar day in the hotel's timezone. Never build one with
50
+ `new Date()` arithmetic in local time; use `eachDate(from, to)`.
51
+ - To close a night send `stopSell: true`. Never a zero price, never zero rooms as a substitute.
52
+ - Writes may reach 365 days ahead. A write is accepted (202) when it is in ZimmerStack's record; it
53
+ reaches the channels in seconds to minutes. `zs.sync.get()` says how far along it is.
54
+
55
+ ## A channel's price modifier
56
+
57
+ - `zs.channels.setModifier(channelId, steps)` moves EVERY price sent to that channel from then on.
58
+ Call it only when a person saved that setting on a screen. Never from a loop, a timer, a seed
59
+ script or a test against a live key. A hotel may change modifiers 6 times a day.
60
+ - 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.
61
+ Show that sentence where the person saves (`MODIFIER_TAKES_EFFECT`), and offer
62
+ `zs.rates.resend()` as a separate, deliberate button ("Apply to nights already on sale"): 3 a day
63
+ per hotel, never automatic.
64
+ - Keep the grid on the price before any modifier; show a channel's price beside it with
65
+ `channelPrice(rate, steps)`.
66
+
67
+ ## Errors
68
+
69
+ ```ts
70
+ import { ZimmerStack, ZimmerStackError } from "@zimmerstack/connect";
71
+
72
+ try {
73
+ await zs.rates.set(updates);
74
+ } catch (err) {
75
+ if (err instanceof ZimmerStackError) {
76
+ // err.code is stable (RATE_LIMITED, RATE_OUT_OF_BAND, SCOPE_MISSING, …); err.message is for people.
77
+ // Show err.message to the person; branch on err.code; never retry unless err.retryable.
78
+ }
79
+ throw err;
80
+ }
81
+ ```
82
+
83
+ - `SCOPE_MISSING`: the key was not given that permission. Say which one is missing; the hotel's
84
+ owner grants it (Admin → Developers → API keys). Do not look for another route.
85
+ - `API_KEY_INVALID`, `API_KEY_REVOKED`, `API_KEY_EXPIRED`: stop. The client refuses every later call
86
+ by itself; repeated bad calls get the server's address refused.
87
+ - `RATE_OUT_OF_BAND`, `MODIFIER_OUT_OF_BAND`: the value is outside what the hotel allows. It is a
88
+ guard against a typing slip; show the message, never split the change into smaller steps to pass.
89
+
90
+ ## The MCP server
91
+
92
+ The package carries an MCP server for you, the agent: `npx -y @zimmerstack/connect mcp`. If it is
93
+ connected, use it instead of guessing: `zimmerstack_reference` looks up any operation, type, limit
94
+ or error code from the API's own contract, and `zimmerstack_sandbox_read` /
95
+ `zimmerstack_sandbox_write` make one call on the sandbox so you can see real ids and try a body
96
+ before you write the code that sends it. It works with a `zsk_test_` key only and refuses a live
97
+ one. It is for building; the application you write calls the API through the client, never through
98
+ these tools.
99
+
100
+ ## Before you call the work done
101
+
102
+ - [ ] The key is read from the environment, on a server, and appears in no committed file or log.
103
+ - [ ] Every screen that writes sends only what the person changed, once, on their action.
104
+ - [ ] No retry loop, no timer and no polling faster than 15 seconds around a call of this package.
105
+ - [ ] Errors show `err.message` to the person and branch on `err.code`.
106
+ - [ ] Tests run against a `zsk_test_` key or a fake `fetch`; none needs a live key.
107
+ - [ ] Where a modifier is saved, the screen says when it takes effect, and the re-send is its own button.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZimmerStack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,240 @@
1
- # Temporary Holding Version
1
+ # @zimmerstack/connect
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The official Node.js client for the [ZimmerStack Connect API](https://docs.zimmerstack.com): read and
4
+ set a hotel's availability, prices and stay rules, price each booking site differently, create
5
+ bookings, and receive the ones the booking sites send.
6
+
7
+ Zero dependencies. Typed from the API's own contract. It keeps the API's rules for you: it paces
8
+ itself, retries only what is safe to retry, and never lets a write land twice.
9
+
10
+ ```bash
11
+ npm install @zimmerstack/connect
12
+ ```
13
+
14
+ Node 20 or newer. **Server only**: the key can change a hotel's prices on every channel, so the
15
+ package refuses to start in a browser or a mobile app. Your frontend calls your server; your server
16
+ calls ZimmerStack. Your app has no server (a Vite, Lovable or Bolt page)? The docs show the smallest
17
+ one: <https://docs.zimmerstack.com/sdk#no-server>. Never put the key in a `VITE_` or `NEXT_PUBLIC_`
18
+ variable: those are sent to every visitor's browser.
19
+
20
+ ## Start
21
+
22
+ **Get a test key.** A software company: [sign up free](https://www.zimmerstack.com/partners/pms-companies#join)
23
+ (your sandbox is made at sign-up), then the [partner portal](https://partner.zimmerstack.com/login) →
24
+ Developers → Create key. A hotel's own developer: the owner makes one in Admin → Developers → API keys.
25
+ A working app to start from: <https://github.com/zimmerstack/connect-starter>.
26
+
27
+ Put the key in the environment, never in code:
28
+
29
+ ```bash
30
+ # .env (not committed). zsk_test_… is a sandbox: nothing you send reaches a channel.
31
+ ZIMMERSTACK_CONNECT_KEY=zsk_test_…
32
+ ```
33
+
34
+ ```ts
35
+ import { ZimmerStack } from "@zimmerstack/connect";
36
+
37
+ const zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY; make one per process and reuse it
38
+
39
+ // The rate grid for a fortnight: rows are room types with their rate plans, columns are nights.
40
+ const grid = await zs.grid.load("2026-12-01", "2026-12-14");
41
+
42
+ // Save what a person changed. Nights are folded into ranges; a large save is split for you.
43
+ const accepted = await zs.grid.save({
44
+ rates: [
45
+ { ratePlanId: 901, date: "2026-12-24", rate: 5200 }, // major units, the hotel's currency: 5200 = 5,200.00
46
+ { ratePlanId: 901, date: "2026-12-25", rate: 5200 },
47
+ ],
48
+ restrictions: [{ ratePlanId: 901, date: "2026-12-31", stopSell: true }], // close a night; never a zero price
49
+ });
50
+
51
+ // Accepted means it is in ZimmerStack's record and on its way to the channels.
52
+ const batch = await zs.batches.wait(accepted[0]!.batchId); // "landed", or still "pending" after five minutes
53
+ ```
54
+
55
+ ## What it does so you do not have to
56
+
57
+ | The API's rule | What the client does |
58
+ |---|---|
59
+ | The key stays on a server | Refuses a browser and React Native. Sends the key to ZimmerStack only. Never prints it: not in errors, not in `console.log(zs)`. |
60
+ | Budgets per minute | Reads the `RateLimit` header on every answer and waits before a budget runs out, instead of earning a refusal. |
61
+ | Writes are never a burst | Sends writes one at a time, in the order you made them. At most four reads at once. |
62
+ | Retry only what passes with time | Retries a used-up budget (429), a fault on ZimmerStack's side (5xx) and a network failure, with a growing wait. Any other refusal is thrown at once, never resent. |
63
+ | A retry must not write twice | Gives every write an idempotency key and reuses it on its retries. A write the server keeps no such record for is not resent when its outcome is unknown. |
64
+ | A request has a size | Splits a write at 1,000 updates or 5,000 cells. |
65
+ | A refused key is not retried | After `API_KEY_INVALID`, `API_KEY_REVOKED` or `API_KEY_EXPIRED` it stops calling. |
66
+ | A test must not touch a real hotel | Refuses to write with a `zsk_live_` key under a test runner. |
67
+
68
+ ## Everything it covers
69
+
70
+ ```ts
71
+ zs.properties.list() // company keys: the hotels this key may act on
72
+ zs.property.get() // timezone, currency, this key's scopes, limits, usage, standing
73
+ zs.catalog.get() // room types and rate plans, with the ids every write uses
74
+ zs.catalog.upsertRoomTypes(…) / upsertRatePlans(…) / deleteRoomType(id) / deleteRatePlan(id)
75
+
76
+ zs.availability.get({ from, to }) / .set(updates)
77
+ zs.rates.get({ from, to }) / .set(updates) / .resend()
78
+ zs.restrictions.get({ from, to }) / .set(updates)
79
+ zs.grid.load(from, to) / zs.grid.save(edits)
80
+
81
+ zs.sync.get() // how far what you sent has travelled
82
+ zs.batches.get(batchId) / .wait(batchId)
83
+
84
+ zs.channels.list() // each booking site and the price modifier it holds
85
+ zs.channels.setModifier(channelId, steps)
86
+
87
+ zs.bookings.create(…) / .get(id) / .list(…) / .cancel(id) // your own booking engine
88
+ zs.channelBookings.list(…) / .get(id) / .all(…) // what the booking sites sent
89
+ zs.sandbox.bookings.create(…) / .cancel(id) / .modify(id, …) // pretend an OTA booked (test keys)
90
+
91
+ zs.request("GET /sync") // any operation of the contract by name, typed
92
+ ```
93
+
94
+ Every request and answer is typed, with the API's own description on each field. Dates are plain
95
+ `YYYY-MM-DD` calendar days in the hotel's timezone. A price is sent in major units and read in minor
96
+ units (`rateMinor`); the grid helpers give and take major units.
97
+
98
+ ## A different price on each booking site
99
+
100
+ One price per rate plan per night goes to every channel. A channel's **modifier** is what differs: a
101
+ few ordered steps applied to every price sent to that channel.
102
+
103
+ ```ts
104
+ import { MODIFIER_TAKES_EFFECT, channelPrice } from "@zimmerstack/connect";
105
+
106
+ const { channels } = await zs.channels.list();
107
+ const booking = channels.find((c) => c.kind === "BookingCom")!;
108
+
109
+ // Booking.com is sent 18 % more, then 200 less. Needs the scope channel-modifiers:write.
110
+ await zs.channels.setModifier(booking.channelId, [
111
+ { action: "increase", type: "percent", value: 18 },
112
+ { action: "decrease", type: "fixed", value: 200 },
113
+ ]);
114
+
115
+ channelPrice(4500, booking.modifier ?? []); // what Booking.com is sent for 4,500: show it beside the grid
116
+ ```
117
+
118
+ `MODIFIER_TAKES_EFFECT` is the sentence to show where a person saves one: a modifier applies to
119
+ prices sent after the change, and prices already on the channel stay until those nights are sent
120
+ again. `zs.rates.resend()` sends them again, unchanged. A hotel may ask a few times a day, so make
121
+ it a button of its own and never call it automatically.
122
+
123
+ One call to `setModifier` moves every price on a channel. Call it when a person saved the setting;
124
+ never from a loop, a timer or a seed script.
125
+
126
+ ## A software vendor's company key
127
+
128
+ A company key reaches many hotels, so every call names one. A **test** company key reaches your
129
+ sandboxes; while you have one, the client finds it by itself and the Start example works unchanged.
130
+ With several, name one. A live key never guesses.
131
+
132
+ ```ts
133
+ const { properties } = await zs.properties.list();
134
+ const hotel = zs.forProperty(properties[0]!.id); // the same client and pace, acting on one hotel
135
+ await hotel.grid.load("2026-12-01", "2026-12-14");
136
+ ```
137
+
138
+ An app that serves one hotel can name it once instead: `ZIMMERSTACK_PROPERTY_ID=61` in the
139
+ environment (or `new ZimmerStack({ propertyId: 61 })`).
140
+
141
+ ## When the API says no
142
+
143
+ ```ts
144
+ import { ZimmerStackError } from "@zimmerstack/connect";
145
+
146
+ try {
147
+ await zs.rates.set(updates);
148
+ } catch (err) {
149
+ if (!(err instanceof ZimmerStackError)) throw err;
150
+ err.code; // stable: "RATE_OUT_OF_BAND", "SCOPE_MISSING", "RATE_LIMITED", … branch on this
151
+ err.message; // a sentence for the person in front of the screen: show it
152
+ err.retryAfterSeconds; // when a budget refused: when to try again
153
+ err.retryable; // false = a verdict on the request. Fix it; never send it again.
154
+ }
155
+ ```
156
+
157
+ The client has already waited and retried where that was worth it. Do not wrap its calls in a retry
158
+ loop of your own.
159
+
160
+ ## Webhooks
161
+
162
+ ```ts
163
+ import { verifyWebhook } from "@zimmerstack/connect";
164
+
165
+ export async function POST(request: Request) {
166
+ // The body exactly as it arrived, before any JSON parsing.
167
+ const event = await verifyWebhook(await request.text(), request.headers, process.env.ZIMMERSTACK_WEBHOOK_SECRET!);
168
+ // Deliveries are at-least-once: remember event.id and skip one you have seen.
169
+ if (event.type === "channel.booking.created") await save(event.data.booking);
170
+ return new Response(null, { status: 204 });
171
+ }
172
+ ```
173
+
174
+ It throws `ZimmerStackWebhookError` for a delivery that is not ZimmerStack's or is older than five
175
+ minutes: answer 400 and do not act on the body.
176
+
177
+ ## Options
178
+
179
+ ```ts
180
+ new ZimmerStack({
181
+ apiKey, // default: process.env.ZIMMERSTACK_CONNECT_KEY
182
+ propertyId, // company keys: the hotel to act on; default ZIMMERSTACK_PROPERTY_ID (or use forProperty)
183
+ timeoutMs: 30_000, // one attempt
184
+ maxRetries: 3, // of what may pass later
185
+ maxWaitSeconds: 120, // the longest it waits for a budget before giving the refusal back
186
+ onEvent: (e) => log(e), // every answer, wait and retry, for your logs; never carries the key
187
+ fetch, // a stand-in for tests
188
+ });
189
+ ```
190
+
191
+ ## Testing your integration
192
+
193
+ Use a `zsk_test_` key (a software company: the partner portal → Developers; a hotel's owner: Admin →
194
+ Developers → API keys), or pass a fake `fetch`. Nothing you do with a test key reaches a channel, and `zs.sandbox.bookings.create`
195
+ sends your webhook endpoint a real delivery.
196
+
197
+ ## For AI coding agents
198
+
199
+ The package ships its own rules file. Add it to the repository's rules so the agent building on this
200
+ package follows it. Append, never copy over: Next.js and other tools write their own `AGENTS.md`.
201
+
202
+ ```bash
203
+ cat node_modules/@zimmerstack/connect/AGENTS.md >> AGENTS.md # or >> CLAUDE.md
204
+ ```
205
+
206
+ The whole API reference in one file an agent can read: <https://docs.zimmerstack.com/llms-full.txt>.
207
+
208
+ ### An MCP server, so the agent looks things up instead of guessing
209
+
210
+ The package also carries an MCP server. Connect it to your coding agent and the agent can read the
211
+ rules, look up any part of the API, and try a call on your sandbox before it writes the code:
212
+
213
+ | Tool | What the agent gets |
214
+ |---|---|
215
+ | `zimmerstack_rules` | The rules for building on the API: the key, pacing, money and dates, a closing checklist. |
216
+ | `zimmerstack_reference` | Any operation, type, limit or error code, from the API's own contract. |
217
+ | `zimmerstack_sandbox_read` | One read on your sandbox: real ids and real shapes. |
218
+ | `zimmerstack_sandbox_write` | One write on your sandbox, to try a body before writing the code that sends it. |
219
+
220
+ ```bash
221
+ # Claude Code
222
+ claude mcp add zimmerstack -- npx -y @zimmerstack/connect mcp
223
+ ```
224
+
225
+ ```json
226
+ // Cursor (.cursor/mcp.json) and Claude Code's project file (.mcp.json)
227
+ { "mcpServers": { "zimmerstack": { "command": "npx", "args": ["-y", "@zimmerstack/connect", "mcp"] } } }
228
+ ```
229
+
230
+ It runs on your own machine. It reads `ZIMMERSTACK_CONNECT_KEY` from the environment, or from your
231
+ project's `.env.local` or `.env`, so the key never goes into the agent's settings file. It uses the
232
+ key only when it is a sandbox key (`zsk_test_…`) and refuses a live one: an agent cannot change a
233
+ real hotel through it. Without a key the rules and the reference still work.
234
+
235
+ ## Links
236
+
237
+ - Guides and reference: <https://docs.zimmerstack.com>
238
+ - Build a rate grid: <https://docs.zimmerstack.com/rate-grid>
239
+ - Prices per channel: <https://docs.zimmerstack.com/per-ota>
240
+ - Limits: <https://docs.zimmerstack.com/limits> · Errors: <https://docs.zimmerstack.com/errors>
@@ -0,0 +1,260 @@
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";
2
+ import { type Grid, type GridEdits, type ModifierStep } from "./grid.js";
3
+ export interface ZimmerStackOptions {
4
+ /**
5
+ * `zsk_test_…` (a sandbox: nothing reaches a channel) or `zsk_live_…`. Defaults to the environment
6
+ * variable `ZIMMERSTACK_CONNECT_KEY`, which is where it should live: never in code, a log or a browser.
7
+ */
8
+ apiKey?: string;
9
+ /** A software vendor's company key only: the hotel every call acts on. See also `forProperty`. */
10
+ propertyId?: number;
11
+ /** Only for a local stand-in of the API while testing (http://localhost:…). The key is sent to no other host. */
12
+ baseUrl?: string;
13
+ /** A replacement for the global `fetch`, for tests. */
14
+ fetch?: typeof fetch;
15
+ /** How long one attempt may take. Default 30 s. */
16
+ timeoutMs?: number;
17
+ /** How many times a request that may pass later is sent again. Default 3 (four attempts in all), at most 5. */
18
+ maxRetries?: number;
19
+ /** The longest the client waits for a budget before giving the refusal back to you. Default 120 s. */
20
+ maxWaitSeconds?: number;
21
+ /**
22
+ * A live key under a test runner (NODE_ENV=test, Vitest, Jest, node --test) may read but not write,
23
+ * because a test that loops would change a real hotel. Set true only for a test that is meant to.
24
+ */
25
+ allowLiveWritesInTests?: boolean;
26
+ /** What the client is doing, for your logs: every answer, every wait, every retry. Never carries the key. */
27
+ onEvent?: (event: ClientEvent) => void;
28
+ }
29
+ export type ClientEvent = {
30
+ type: "response";
31
+ operation: string;
32
+ status: number;
33
+ attempt: number;
34
+ ms: number;
35
+ } | {
36
+ type: "retry";
37
+ operation: string;
38
+ attempt: number;
39
+ waitMs: number;
40
+ reason: string;
41
+ } | {
42
+ type: "pace";
43
+ operation: string;
44
+ waitMs: number;
45
+ };
46
+ /** Per-call options of a write. */
47
+ export interface WriteOptions {
48
+ /**
49
+ * Your own key for this write (10 to 64 of A–Z a–z 0–9 _ -), when a retry may come from another
50
+ * process: the same key with the same body within 7 days replays the first answer instead of
51
+ * writing twice. Without one the client makes a fresh key and reuses it on its own retries.
52
+ */
53
+ idempotencyKey?: string;
54
+ signal?: AbortSignal;
55
+ }
56
+ export interface ReadOptions {
57
+ signal?: AbortSignal;
58
+ }
59
+ type Op<K extends OperationKey> = Operations[K];
60
+ /** What `request` takes for an operation: its path values, its query, its body. */
61
+ export type RequestArgs<K extends OperationKey> = (Op<K>["path"] extends undefined ? {
62
+ path?: undefined;
63
+ } : {
64
+ path: Op<K>["path"];
65
+ }) & (Op<K>["query"] extends undefined ? {
66
+ query?: undefined;
67
+ } : {
68
+ query?: Op<K>["query"];
69
+ }) & (Op<K>["body"] extends undefined ? {
70
+ body?: undefined;
71
+ } : {
72
+ body: Op<K>["body"];
73
+ }) & WriteOptions;
74
+ /**
75
+ * The ZimmerStack Connect API, from your server.
76
+ *
77
+ * @example
78
+ * import { ZimmerStack } from "@zimmerstack/connect";
79
+ *
80
+ * const zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY
81
+ * const grid = await zs.grid.load("2026-12-01", "2026-12-14");
82
+ * await zs.grid.save({ rates: [{ ratePlanId: 901, date: "2026-12-24", rate: 5200 }] });
83
+ *
84
+ * Make one per process and reuse it: the pace it keeps is per instance.
85
+ */
86
+ export declare class ZimmerStack {
87
+ #private;
88
+ /** "test" on a sandbox key: nothing you send reaches a channel. */
89
+ readonly mode: "live" | "test";
90
+ /** The hotel a company key acts on through this instance. */
91
+ readonly propertyId: number | undefined;
92
+ constructor(options?: ZimmerStackOptions);
93
+ /**
94
+ * A software vendor's company key: the same client, acting on one hotel. Shares this client's pace,
95
+ * so make as many as you have hotels.
96
+ *
97
+ * @example
98
+ * const { properties } = await zs.properties.list();
99
+ * for (const p of properties) await zs.forProperty(p.id).sync.get();
100
+ */
101
+ forProperty(propertyId: number): ZimmerStack;
102
+ /** Never prints the key. */
103
+ toJSON(): {
104
+ mode: string;
105
+ propertyId: number | undefined;
106
+ };
107
+ /**
108
+ * Any operation of the contract by its name, typed. The methods below are this with friendlier names;
109
+ * use it for an operation they do not cover.
110
+ *
111
+ * @example
112
+ * const sync = await zs.request("GET /sync");
113
+ */
114
+ request<K extends OperationKey>(operation: K, ...rest: {} extends RequestArgs<K> ? [args?: RequestArgs<K>] : [args: RequestArgs<K>]): Promise<Op<K>["response"]>;
115
+ readonly properties: {
116
+ /** The hotels this key may act on. A company key names one of them on every other call (`forProperty`). */
117
+ list: (options?: ReadOptions) => Promise<import("./generated.js").Properties>;
118
+ };
119
+ readonly property: {
120
+ /** The hotel: its timezone and currency, what this key may do, its own limits, what it has used, where it stands. */
121
+ get: (options?: ReadOptions) => Promise<import("./generated.js").Property>;
122
+ };
123
+ readonly catalog: {
124
+ /** Room types and rate plans, with the numeric ids every write uses. */
125
+ get: (options?: ReadOptions) => Promise<Catalog>;
126
+ /** Create or change room types by your own `ref`. Needs the scope catalog:write. */
127
+ upsertRoomTypes: (body: RoomTypesUpsert, options?: WriteOptions) => Promise<import("./generated.js").CatalogUpsertResult>;
128
+ /** Delete a room type; its rate plans go with it. */
129
+ deleteRoomType: (roomTypeId: number, options?: ReadOptions) => Promise<import("./generated.js").CatalogDeleteResult>;
130
+ /** Create or change rate plans by your own `ref`. */
131
+ upsertRatePlans: (body: RatePlansUpsert, options?: WriteOptions) => Promise<import("./generated.js").CatalogUpsertResult>;
132
+ deleteRatePlan: (ratePlanId: number, options?: ReadOptions) => Promise<import("./generated.js").CatalogDeleteResult>;
133
+ };
134
+ readonly availability: {
135
+ /** Rooms left to sell per room type per night, as ZimmerStack's record holds them. Up to 500 days. */
136
+ get: (range?: {
137
+ from?: string;
138
+ to?: string;
139
+ }, options?: ReadOptions) => Promise<import("./generated.js").AvailabilityRead>;
140
+ /**
141
+ * Set rooms left to sell: absolute numbers over date ranges. Answers when the values are in
142
+ * ZimmerStack's record (one answer per request sent; a large write is split for you).
143
+ */
144
+ set: (updates: AvailabilityWrite["updates"], options?: WriteOptions) => Promise<WriteAccepted[]>;
145
+ };
146
+ readonly rates: {
147
+ /** Nightly prices per rate plan, in MINOR units (`rateMinor`), before any channel's modifier. */
148
+ get: (range?: {
149
+ from?: string;
150
+ to?: string;
151
+ }, options?: ReadOptions) => Promise<import("./generated.js").RatesRead>;
152
+ /**
153
+ * Set nightly prices in MAJOR units over date ranges (4500 = ₹4,500.00). `currency` may be left
154
+ * out: the hotel's own is filled in. To close a night use `restrictions.set` with stopSell,
155
+ * never a zero price.
156
+ */
157
+ set: (updates: Array<Omit<RatesWrite["updates"][number], "currency"> & {
158
+ currency?: string;
159
+ }>, options?: WriteOptions) => Promise<WriteAccepted[]>;
160
+ /**
161
+ * Send the hotel's prices to its channels again, unchanged, so nights already there pick the
162
+ * current modifiers up. A hotel may ask a few times a day: make it a deliberate button, never
163
+ * automatic. Watch `rates.dirtyCells` on `sync.get()` fall to 0.
164
+ */
165
+ resend: (options?: WriteOptions) => Promise<RatesResendAccepted>;
166
+ };
167
+ readonly restrictions: {
168
+ /** The stay rules per rate plan per night; null = no rule set for that field. */
169
+ get: (range?: {
170
+ from?: string;
171
+ to?: string;
172
+ }, options?: ReadOptions) => Promise<import("./generated.js").RestrictionsRead>;
173
+ /** Set stay rules over date ranges: stopSell, closedToArrival, closedToDeparture, minStayArrival, minStayThrough, maxStay. */
174
+ set: (updates: RestrictionsWrite["updates"], options?: WriteOptions) => Promise<WriteAccepted[]>;
175
+ };
176
+ readonly sync: {
177
+ /** How far what you sent has travelled: cells still on their way, the last error, where the integration stands. */
178
+ get: (options?: ReadOptions) => Promise<import("./generated.js").SyncStatus>;
179
+ };
180
+ readonly batches: {
181
+ /** One write, by the `batchId` its answer carried. */
182
+ get: (batchId: string, options?: ReadOptions) => Promise<BatchStatus>;
183
+ /**
184
+ * Wait for a write to reach the channels, asking no more often than every 15 seconds, for at most
185
+ * five minutes. Returns the last status: if it is still "pending", say "still syncing" and let the
186
+ * person look again later. Availability lands in seconds; a full calendar of prices takes minutes.
187
+ */
188
+ wait: (batchId: string, options?: {
189
+ timeoutMs?: number;
190
+ intervalMs?: number;
191
+ signal?: AbortSignal;
192
+ }) => Promise<BatchStatus>;
193
+ };
194
+ readonly channels: {
195
+ /**
196
+ * The connected channels (Booking.com, MakeMyTrip, …), each with the price modifier it holds:
197
+ * `[]` = prices go as they are; `null` = a rule set by hand that this API cannot express.
198
+ */
199
+ list: (options?: ReadOptions) => Promise<import("./generated.js").Channels>;
200
+ /**
201
+ * Replace a channel's modifier with these steps (`[]` removes it). Needs the scope
202
+ * channel-modifiers:write.
203
+ *
204
+ * ONE CALL MOVES EVERY PRICE SENT TO THAT CHANNEL FROM THEN ON. Call it when a person saved the
205
+ * setting; never from a loop, a timer or a test against a live key. Prices already on the channel
206
+ * stay as they are until those nights are sent again (`rates.resend`).
207
+ */
208
+ setModifier: (channelId: string, steps: ModifierStep[], options?: WriteOptions) => Promise<ModifierResult>;
209
+ };
210
+ readonly bookings: {
211
+ /** Bookings this integration created, newest first. */
212
+ list: (query?: Op<"GET /bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").BookingsList>;
213
+ /**
214
+ * Create a booking in the hotel's PMS. Always send `externalReference` (your own reservation id):
215
+ * the same value returns the same booking, which makes every retry safe.
216
+ */
217
+ create: (body: BookingCreate, options?: WriteOptions) => Promise<Booking>;
218
+ get: (bookingId: number, options?: ReadOptions) => Promise<Booking>;
219
+ /** Cancel a booking this integration created; its nights open again on the channels. */
220
+ cancel: (bookingId: number, body?: BookingCancel, options?: ReadOptions) => Promise<Booking>;
221
+ };
222
+ readonly channelBookings: {
223
+ /** OTA bookings the channel manager delivered, in the webhook's shape. Follow `nextCursor`, or use `all`. */
224
+ list: (query?: Op<"GET /channel-bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").ChannelBookingsList>;
225
+ get: (bookingId: number, options?: ReadOptions) => Promise<ChannelBooking>;
226
+ /**
227
+ * Every OTA booking changed since `since`, page by page, for reconciling what your webhook missed.
228
+ *
229
+ * @example
230
+ * for await (const booking of zs.channelBookings.all({ since: lastSeen })) save(booking);
231
+ */
232
+ all: (query?: Omit<NonNullable<Op<"GET /channel-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
233
+ };
234
+ readonly sandbox: {
235
+ bookings: {
236
+ 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. */
238
+ create: (body: SandboxBookingCreate, options?: WriteOptions) => Promise<import("./generated.js").SandboxBooking>;
239
+ cancel: (bookingId: number, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
240
+ modify: (bookingId: number, body: SandboxBookingModify, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
241
+ };
242
+ };
243
+ readonly grid: {
244
+ /**
245
+ * The whole grid for a window, ready for a screen: rows are room types with their rate plans,
246
+ * columns are nights. Three reads (four the first time). A window may span 500 days; a screen
247
+ * needs 14 to 60.
248
+ */
249
+ load: (from: string, to: string, options?: ReadOptions) => Promise<Grid>;
250
+ /**
251
+ * Save what a person changed: single nights in, the fewest ranges out, one request per resource,
252
+ * one after another. Each answer carries a `batchId`: the values are in ZimmerStack's record and
253
+ * on their way to the channels.
254
+ */
255
+ save: (edits: GridEdits, options?: {
256
+ signal?: AbortSignal;
257
+ }) => Promise<WriteAccepted[]>;
258
+ };
259
+ }
260
+ export {};