@zimmerstack/connect 0.6.0 → 0.9.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.
Files changed (51) hide show
  1. package/AGENTS.md +269 -15
  2. package/README.md +451 -18
  3. package/dist/cjs/client.d.ts +503 -13
  4. package/dist/cjs/client.js +743 -45
  5. package/dist/cjs/doctor.d.ts +86 -0
  6. package/dist/cjs/doctor.js +689 -0
  7. package/dist/cjs/errors.d.ts +6 -2
  8. package/dist/cjs/errors.js +7 -2
  9. package/dist/cjs/generated.d.ts +2921 -207
  10. package/dist/cjs/generated.js +222 -8
  11. package/dist/cjs/grid.d.ts +6 -1
  12. package/dist/cjs/grid.js +8 -0
  13. package/dist/cjs/index.d.ts +14 -5
  14. package/dist/cjs/index.js +41 -1
  15. package/dist/cjs/key.d.ts +39 -0
  16. package/dist/cjs/key.js +85 -0
  17. package/dist/cjs/money.d.ts +81 -0
  18. package/dist/cjs/money.js +172 -0
  19. package/dist/cjs/notices.d.ts +44 -0
  20. package/dist/cjs/notices.js +64 -0
  21. package/dist/cjs/shownOnce.d.ts +42 -0
  22. package/dist/cjs/shownOnce.js +83 -0
  23. package/dist/cjs/webhooks.d.ts +182 -3
  24. package/dist/cjs/webhooks.js +75 -1
  25. package/dist/esm/client.d.ts +503 -13
  26. package/dist/esm/client.js +741 -45
  27. package/dist/esm/doctor.d.ts +86 -0
  28. package/dist/esm/doctor.js +685 -0
  29. package/dist/esm/errors.d.ts +6 -2
  30. package/dist/esm/errors.js +7 -2
  31. package/dist/esm/generated.d.ts +2921 -207
  32. package/dist/esm/generated.js +221 -7
  33. package/dist/esm/grid.d.ts +6 -1
  34. package/dist/esm/grid.js +7 -0
  35. package/dist/esm/index.d.ts +14 -5
  36. package/dist/esm/index.js +8 -3
  37. package/dist/esm/key.d.ts +39 -0
  38. package/dist/esm/key.js +81 -0
  39. package/dist/esm/mcp/cli.js +88 -9
  40. package/dist/esm/mcp/reference.generated.js +4464 -974
  41. package/dist/esm/mcp/server.d.ts +14 -6
  42. package/dist/esm/mcp/server.js +451 -25
  43. package/dist/esm/money.d.ts +81 -0
  44. package/dist/esm/money.js +161 -0
  45. package/dist/esm/notices.d.ts +44 -0
  46. package/dist/esm/notices.js +56 -0
  47. package/dist/esm/shownOnce.d.ts +42 -0
  48. package/dist/esm/shownOnce.js +77 -0
  49. package/dist/esm/webhooks.d.ts +182 -3
  50. package/dist/esm/webhooks.js +69 -0
  51. package/package.json +1 -1
package/AGENTS.md CHANGED
@@ -26,32 +26,268 @@ https://docs.zimmerstack.com/llms-full.txt
26
26
  - No key yet: a software company signs up, free, at https://www.zimmerstack.com/partners/pms-companies#join
27
27
  and makes test keys in the partner portal (Developers); a hotel's owner makes one in Admin →
28
28
  Developers → API keys.
29
+ - A key is zsk_live_ (or zsk_test_ on a sandbox) + 40 letters and digits + a 6-character checksum (the CRC32 of everything before it, in base 62), so a key can be told from a look-alike without asking us. Where a person pastes a key (a settings screen, a
30
+ deploy script), check it with `checkKey(value)` first: it tells a mistyped or cut-short key from a real
31
+ one without sending it anywhere, and its `message` never contains the key.
32
+ - The key your code runs on is replaced by a person, never by code: no route makes, rotates or revokes
33
+ a hotel's own key or a company key. Every key can be rotated, company keys included: the new key is shown once and the old one keeps answering for 24 hours, then answers 401 API_KEY_REVOKED. A key reported as found in a public place (for example by GitHub secret scanning in a public repository) is revoked at once and its holder is emailed: requests on it answer 401 API_KEY_REVOKED.
34
+ So when calls suddenly answer `API_KEY_REVOKED`, do not retry: tell the person to make a new key.
35
+ (The one thing that is by API: the keys a software partner made on a hotel, below.)
36
+ - When something is wrong, run `npx @zimmerstack/connect doctor` before changing code: it checks the
37
+ key, the hotels and scopes it reaches, every budget, the last day's refused requests, the webhook
38
+ endpoints and the sync state, and says what to do about each. It only reads and never prints the key.
29
39
 
30
40
  ## Let the package pace; never work around it
31
41
 
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.
42
+ - It reads every budget in the `RateLimit` headers and slows down before one runs out, and sends one
43
+ hotel's writes one at a time, in order. It sends a request again only when that is safe: a 429
44
+ always, after its `Retry-After`; a 5xx or a network failure only for a read, or for a write that
45
+ carries an idempotency key (a delete carries none, and is never sent twice). Anything else is a
46
+ `ZimmerStackError` at once. Do not wrap its calls in your own retry loop, and never resend a 4xx
47
+ other than 429: it is a verdict on the request. Fix the request.
36
48
  - 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.
49
+ A write is every call that is not a read. A hotel also has budgets per hour and per day that count
50
+ CHANGED cells (at least 10,000 an hour, 30,000
51
+ a day). Hitting one is `error.code === "RATE_LIMITED"` with `error.retryAfterSeconds` and
52
+ `error.freesAt`: tell the person when to try again; do not sleep through an hour. A job that may wait
53
+ passes `{ maxWaitSeconds: 3600 }` on the call: the package then holds it and tells `onEvent` when it
54
+ lands. `zs.limits.get()` answers every budget with what is left of it.
40
55
  - One instance per process (`new ZimmerStack()` once, in a module). Two instances do not share a pace.
56
+ Under a company key each hotel (`zs.forProperty(id)`) has its own queue and its own pace: one hotel's
57
+ budget never holds up another's calls.
41
58
  - Never write on a timer, in a loop over all nights, or "to be safe". Send what a person changed,
42
59
  when they changed it: `zs.grid.save(edits)` folds nights into ranges and splits a large save.
43
60
  - Do not poll faster than every 15 seconds (`zs.batches.wait` already does it right), and stop.
44
61
 
62
+ ## Every limit, from the API's own table
63
+
64
+ The package keeps inside these by itself; they are here so you can size a job. `zs.limits.get()` answers
65
+ the same rows for your key with what is left of each. "At least" is what the smallest hotel gets: a larger
66
+ hotel gets more, and `zs.limits.get()` says exactly.
67
+
68
+ - `api-address`: 1,200 requests, 60 s fixed, per address, on each API machine.
69
+ - `ip`: 240 requests, 60 s sliding, per address.
70
+ - `ip-auth`: 20 failed authentications, 60 s sliding, per address.
71
+ - `key-auth`: 5 failed authentications, 60 s sliding, per address and key.
72
+ - `global-unauthenticated`: 1,200 requests, 60 s sliding, per everyone without a verified key.
73
+ - `requests`: 120 requests, 60 s sliding, per key.
74
+ - `writes`: 30 writes, 60 s sliding, per key.
75
+ - `property`: 300 requests, 60 s sliding, per property (all its keys).
76
+ - `property-writes`: 60 writes, 60 s sliding, per property (all its keys).
77
+ - `cells`: 20,000 cells, 60 s sliding, per property (all its keys).
78
+ - `company`: 1,200 requests, 60 s sliding, per company key (all its hotels).
79
+ - `global`: 3,000 requests, 60 s sliding, per everyone.
80
+ - `bookings`: 20 bookings, 60 s sliding, per key.
81
+ - `property-bookings`: 40 bookings, 60 s sliding, per property (all its keys).
82
+ - `property-bookings-day`: 500 bookings, rolling 24 hours, per property (all its keys).
83
+ - `direct-cancels`: 10 cancels, 60 s sliding, per key.
84
+ - `property-direct-cancels-day`: 50 cancels, rolling 24 hours, per property (all its keys).
85
+ - `cells-hour`: at least 10,000 changed cells, one clock hour (UTC), per property (all its keys).
86
+ - `cells-day`: at least 30,000 changed cells, rolling 24 hours, per property (all its keys).
87
+ - `vendor-cells-day`: at least 150,000 changed cells, rolling 24 hours, per software vendor (all its hotels).
88
+ - `shield-lane`: at least 500 closing cells, one clock hour (UTC), per property (all its keys).
89
+ - `structure-creates`: 20 new room types and rate plans, 60 s sliding, per property.
90
+ - `structure-creates-day`: 300 new room types and rate plans, rolling 24 hours, per property.
91
+ - `structure-edits-day`: 300 changed room types and rate plans, rolling 24 hours, per property.
92
+ - `structure-deletes-day`: 60 deleted room types and rate plans, rolling 24 hours, per property.
93
+ - `vendor-structure-creates-day`: at least 500 new room types and rate plans, rolling 24 hours, per software vendor (all its hotels).
94
+ - `vendor-remote-properties-day`: 10 hotels, rolling 24 hours, per software vendor.
95
+ - `vendor-property-removals-day`: 10 hotels, rolling 24 hours, per software vendor.
96
+ - `partner-new-properties-hour`: 20 hotels, one hour, per software partner.
97
+ - `partner-new-sandboxes-hour`: 30 sandboxes, rolling hour, per software partner.
98
+ - `connect-links-hour`: 10 connect links, rolling hour, per property.
99
+ - `partner-connect-links-hour`: 120 connect links, rolling hour, per software partner.
100
+ - `modifier-changes-day`: 6 changes, rolling 24 hours, per property.
101
+ - `rate-resends-day`: 3 re-sends, rolling 24 hours, per property.
102
+ - `partner-support-tickets-day`: 20 tickets, rolling 24 hours, per software partner.
103
+ - `partner-support-messages-hour`: 60 messages, rolling hour, per software partner.
104
+ - `maxUpdatesPerRequest`: 1,000 entries, per request.
105
+ - `maxCellsPerRequest`: 5,000 cells, per request.
106
+ - `maxBodyBytes`: 1,048,576 bytes, per request.
107
+ - `horizonDays`: 500 nights, per request.
108
+ - `maxNightsPerBooking`: 90 nights, per request.
109
+ - `newEntitiesPerRequest`: 20 new room types and rate plans, per request.
110
+ - `maxRoomTypes`: 18 room types, per property.
111
+ - `maxRatePlans`: 180 rate plans, per property.
112
+ - `maxActiveKeysPerProperty`: 5 keys, per property.
113
+ - `maxActiveCompanyKeys`: 5 keys, per software partner.
114
+ - `maxSandboxes`: 5 sandboxes, per software partner.
115
+ - `maxAllowedCidrs`: 20 addresses or ranges, per key.
116
+ - `idempotencyRetentionDays`: 7 days, per key.
117
+ - `maxSupportMessageChars`: 5,000 characters, per request.
118
+ - `maxSupportTicketProperties`: 200 hotels, per request.
119
+
45
120
  ## Money and dates
46
121
 
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.
122
+ - A price is SENT and READ in major units of the hotel's own currency, with that currency's own decimals (ISO 4217: 2 for
123
+ rupees, euros and dollars, 0 for yen; `decimals` on `GET /property`). Send a number or a decimal string (4500.50 or
124
+ "4500.50"); read `rate` ("4500.50") beside `currency` and `decimals`. It is kept exactly: never round a price yourself.
125
+ `zs.grid.load` gives major units; `zs.grid.save` takes them.
126
+ - `rateMinor` and every other `…Minor` field is HUNDREDTHS of the major unit for every currency (450050 = 4500.50;
127
+ 1500000 = 15000 yen), which is the ISO minor unit only where the currency has two decimals. Prefer `rate`.
128
+ - A price with more decimals than the currency has, a number or a decimal string alike, is rounded and named in
129
+ the answer's `rounded` list: show that list to the person, never hide it.
130
+ - Never do money arithmetic on floats, and never divide by 100 yourself. The package's helpers work on the
131
+ strings: `toAmount(value, decimals)`, `addAmounts`, `subtractAmounts`, `multiplyAmount(amount, factor, decimals)`,
132
+ `compareAmounts`, `formatAmount(amount, { currency, decimals, locale })`. A ledger that stores whole minor
133
+ units (cents, paise, yen) converts with `amountFromMinorUnits` and `amountToMinorUnits`; an API `…Minor`
134
+ field becomes the string with `amountFromHundredths(rateMinor, decimals)`. `decimals` always comes from the
135
+ API's answer, never from a table of your own.
49
136
  - A date is a plain `YYYY-MM-DD` calendar day in the hotel's timezone. Never build one with
50
137
  `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
138
+ - `stopSell: true` closes ONE rate plan on that night: a switch. The room type's other rate plans keep
139
+ selling, and so does a rate an OTA derives on its own side. A room count of 0 (`zs.availability.set`)
140
+ is a COUNT: it closes the room type everywhere, and an OTA cancellation or your next count moves it. To
141
+ close a room type and keep it closed, do both in one call: `zs.availability.close` (below). Say which
142
+ of these a button does. Never a zero price.
143
+ - Writes may reach 500 days ahead. A write is accepted (202) when it is in ZimmerStack's record; it
53
144
  reaches the channels in seconds to minutes. `zs.sync.get()` says how far along it is.
54
145
 
146
+ ## Sent is not held: read what comes back
147
+
148
+ - A 202 says "in ZimmerStack's record", not "on the booking sites". Show "saving" until
149
+ `zs.batches.wait(batchId)` reads `landed`. `failed` is not a network error to retry: the channel
150
+ manager refused a value (`parkedCells`, `lastError`) or the write named a room type or rate plan that
151
+ reaches no channel (`unreachable`). A refused value is held, not sent again: send a corrected value for
152
+ those nights. Sending the same value again is refused with the same words.
153
+ - Read every write's answer, not only its status: `rejected` (cells not written, with the reason),
154
+ `rounded` (prices kept differently from what was sent), `priceWarnings` and `warnings`. Show them to the
155
+ person who saved.
156
+ - A value that ZimmerStack's record and the channel manager both already hold is dropped as unchanged
157
+ (`noopCells`): it is not sent again. So sending the same grid twice does no harm, and it does not
158
+ "refresh" the channels either: never resend on a timer to be safe.
159
+ - Someone can change a price or a stay rule on the channel manager's side or in an OTA's extranet. A
160
+ nightly read finds it: `channel.drift.detected` names the nights (`data.drift.cells`, your value and
161
+ theirs), your value is sent again unless the hotel switched that repair off, and `channel.drift.healed`
162
+ follows when a later read agrees. `zs.sync.get()` carries `rates.driftCells`. Show it; never answer it
163
+ by pushing the whole calendar every night.
164
+ - `channel.sync.alert` says a problem began (`data.sync.event`: a refused value, a disconnect, prices or
165
+ room counts that stopped going out, a setting changed) and `channel.sync.recovered` that it ended. Show
166
+ both to the hotel; neither is a reason to resend everything.
167
+ - A night more than a year ahead that your software never wrote is closed on the booking sites. A room
168
+ count you write for it is sent as written; otherwise it opens by itself when it comes inside the year.
169
+
170
+ ## See what a write will do, and read what it did not do
171
+
172
+ - Every answer of `zs.availability.set`, `zs.rates.set` and `zs.restrictions.set` may carry `notices`: what
173
+ the write did NOT do, one sentence each with a stable `code`, a `level` (warning or info) and an
174
+ `action`. Read them after every save with `noticesOf(accepted)` and show the warnings to the person
175
+ who saved (`message` and `action`). Branch on `code` (`NOTICES` lists all 19 with what each
176
+ means); a code you do not know was added later, so show it too. A notice is never an error: the write
177
+ was accepted.
178
+ - The two that explain most surprises: `ROOM_STILL_ON_SALE` (you stop-sold one rate plan and the room
179
+ still sells through `otherRatePlanIds`) and `COUNT_ZERO_IS_NOT_STOP_SELL` (a count of 0 is a count, which
180
+ the next OTA cancellation or your next count moves).
181
+ - `zs.availability.dryRun(updates)`, `zs.rates.dryRun(updates)` and `zs.restrictions.dryRun(updates)` answer
182
+ what the same `set` WOULD do and write nothing: a `WritePreview` (`dryRun: true`, `verdict`, what would
183
+ change, what is already held, the notices), never a `WriteAccepted`. Use one before a large or unusual
184
+ write, or to show a person what a button will do. It spends the minute budgets like the write it
185
+ previews (one request, one write, the same cells), so it is not a free read of the calendar: never
186
+ dry-run on a timer or to "check" a night. `zs.rates.get` and its siblings are the reads.
187
+ - `zs.availability.close({ roomTypeId, dateFrom, dateTo })` closes one room type on those nights everywhere:
188
+ its count goes to 0 and stop-sell is switched on for every one of its rate plans. Read `notReached` in
189
+ the answer: it names what the close could not reach (a rate an OTA links on its own side is closed only
190
+ by the count). `zs.availability.reopen` undoes exactly that close; pass `available` when your software
191
+ knows how many rooms are free now. `closeDryRun` and `reopenDryRun` show what each would do. Call
192
+ close and reopen from a person's action or a rule a person set; never from a loop over all rooms.
193
+ - When a person asks "why is this night not selling as we sent it", call
194
+ `zs.explain.night({ roomTypeId, date })` and show its `summary`: what your software last sent, what
195
+ ZimmerStack's record holds and who set it, what the channel manager was last seen holding, and any
196
+ value it refused, in its own words. It reads the channel manager's copy as last seen, never a booking
197
+ site's own screen; `seenAt: null` means "never read back", not "wrong". Never loop it over a calendar.
198
+
199
+ ## Bookings and events: the webhook is the nudge, the log is the truth
200
+
201
+ - Every event of a hotel (an OTA booking arriving, changing, cancelled; a website booking; a channel
202
+ problem and its end; drift) has a `sequence`, one higher than the hotel's last. The webhook carries it,
203
+ and `GET /events` lists every event once, in that order, for 90 days.
204
+ - Build the receiver so nothing depends on a delivery: verify it (`verifyWebhook`), answer 2xx at once,
205
+ then read the log from the place you saved:
206
+ `for await (const event of zs.events.all({ after: place })) { apply(event); place = event.sequence; }`
207
+ and save `place` with what you applied, in one transaction. Run the same loop on a schedule (every few
208
+ minutes is plenty) and after a restart: a missed, repeated or out-of-order delivery then changes nothing.
209
+ - `event.data.booking.version` counts a booking's events (1, 2, 3 …). A copy you hold with a higher
210
+ version is newer than the event in your hand: do not overwrite it.
211
+ - `onGap` on `zs.events.all` fires when the log no longer holds what follows your place (a first run, or
212
+ an outage longer than the log keeps): read `zs.channelBookings.all({ since })` and
213
+ `zs.directBookings.all({ since })`, then carry on from the log.
214
+ - Narrow an event with `isOtaBookingEvent`, `isWebsiteBookingEvent`, `isSyncEvent`, `isDriftEvent`,
215
+ `isConnectEvent`. A type you do not know is skipped, never an error: new types are added without notice.
216
+ - Two families are about your ACCOUNT, not one hotel: `platform.incident.*` (`isIncidentEvent`) and
217
+ `support.ticket.*` (`isSupportTicketEvent`). They carry no `property` and no `sequence` and are not in
218
+ the event log. Check for them BEFORE any code that reads `event.property`; `zs.status.get()` and
219
+ `zs.supportTickets.get(id)` are the reads behind them.
220
+ - A cancelled room stays in `rooms[]` with `status: "CANCELLED"`; `stay` and `occupancy` count the rooms
221
+ still live. `finance.virtualCard: true` means the OTA pays the hotel with a card it issues: the guest
222
+ owes the desk nothing for the room. No card number is ever sent.
223
+
224
+ ## Guest contact
225
+
226
+ - A guest's phone and email are returned by the API until 30 days after checkout. After that guest.phone and guest.email are null and guest.contactWithheld says "retention", so you can tell withheld from a booking that never had one. The name, the stay and the money stay.
227
+ Copy what you need into your own system when the booking arrives; do not plan to read it back later.
228
+ - `guest.contactWithheld` says why `phone` and `email` are null: `"retention"` is final, `"unavailable"`
229
+ means ask again. Never treat null as "the guest gave none" when it is set.
230
+ - Every read that returned contact is logged (the key, the partner behind it, when, which bookings) and the hotel's owner sees the list. Read contact only where a person needs it.
231
+ - An endpoint receives phone and email only while its owner has guest contact switched on; it can be switched at any time. A partner's company endpoint starts with it off.
232
+
233
+ ## Webhook endpoints by API (a software partner's company key)
234
+
235
+ - With the scope `webhooks:manage` a company key creates, changes, pauses, resumes, tests and recovers
236
+ its own company webhook endpoints: `zs.webhookEndpoints.*`. No hotel is named: an endpoint is the
237
+ partner's. A test key manages test endpoints (your sandboxes' events), a live key live ones.
238
+ - The signing secret is in the answer of `zs.webhookEndpoints.create` and `.rotateSecret`, once. Store it
239
+ in the server's settings at that moment (never in code, a log or a chat); no call reads it back.
240
+ - Before planned downtime call `zs.webhookEndpoints.pause`: events are held and `resume` sends them, oldest
241
+ first. After an outage call `zs.webhookEndpoints.recover(id, since)`, or simply read the log.
242
+ - `zs.webhookEndpoints.delete` is for good and takes the delivery log with it: only on a person's action.
243
+
244
+ ## Going live, connect links and a hotel's keys (a software partner's company key)
245
+
246
+ - A hotel you add (`zs.properties.create`) is live from the start. A hotel that let you in by your vendor
247
+ code is not: until it is, a call that names it answers `ARI_NOT_AUTHORITATIVE`.
248
+ `zs.forProperty(id).readiness.get()` answers four checks, each with a sentence and what to do.
249
+ - To send a year first, pass `{ beforeGoLive: true }` on each call: `zs.rates.set(prices, { beforeGoLive: true })`.
250
+ Prices and stay rules sent this way are stored and wait (the answer says `heldUntilGoLive: true`).
251
+ A price for every rate plan and night of the year ahead is what the readiness report asks for.
252
+ - ROOM COUNTS ARE NOT SENT AHEAD. Until the hotel is live a room count may only LOWER what is on sale:
253
+ one at or below what is on sale goes to the booking sites at once (a held count would oversell a
254
+ room), and one that raises it is refused in the answer's `rejected` list (`NOTHING_ACCEPTED` when
255
+ nothing else in the request landed), because the hotel's own people may still be running its counts.
256
+ Do not loop on that refusal and do not try to work around it: send the room counts with
257
+ `zs.availability.set` right after `goLive` answers.
258
+ - `zs.readiness.goLive()` makes your software the hotel's source of truth. Call it when a person decided
259
+ to, once `ready` is true. `NOT_READY` lists the checks that did not pass (`err.details`): fix them and
260
+ call again; never retry it in a loop. Only ZimmerStack support switches a hotel back.
261
+ - Connecting a booking site: `zs.connectLinks.create({ propertyId, channel })` (scope `channels:connect`,
262
+ a LIVE key: a test key is refused) answers a one-time `url` for the hotel's own person, who signs in
263
+ to the booking site and confirms every room and rate match on ZimmerStack's page. Never ask a hotel for
264
+ a booking site's password, never store one, and never build a screen that takes one: no call accepts it.
265
+ Listen for `channel.connect.completed` and `channel.connect.expired` (match on `data.connect.linkId`).
266
+ - `zs.hotelKeys.list`, `.create`, `.rotate` and `.revoke` (scope `keys:manage`) manage the keys you made on
267
+ a hotel you added; never a company key, never the hotel's own. A rotation makes a new key with the same name, scopes, addresses and expiry; the old one keeps answering for 24 hours (retireAt), then stops.
268
+ - A VALUE SHOWN ONCE is in one answer and nowhere else: the `key` of `zs.hotelKeys.create` and `.rotate`,
269
+ the `url` of `zs.connectLinks.create`, the `secret` of `zs.webhookEndpoints.create` and `.rotateSecret`.
270
+ Take it with `shownOnce(answer)` and put it in the server's secret store in the same step. It is null
271
+ on a retry of the same request: `shownOnce` then throws `ZimmerStackShownOnceError`, whose `nextStep`
272
+ names the call that gets a new one. Never write code that stores `answer.key ?? ""`. Log
273
+ `withoutShownOnce(answer)`, never the answer itself.
274
+
275
+ ## Billing, support and status (a software partner's company key)
276
+
277
+ - `zs.billing.get()`, `.invoices()` and `.nextInvoice()` (scope `billing:read`) READ what the partner
278
+ portal's Billing page shows. Nothing pays or changes anything by API. Amounts are decimal strings in
279
+ major units beside `…Minor`: use the money helpers, and never add amounts of two currencies.
280
+ - `atCost` on `zs.billing.get()` lists what the channel manager charged above its included room types and
281
+ rate plans, passed on at cost. An item with `status: "RECORDED"` is on no invoice yet: show it as
282
+ recorded, never as billed.
283
+ - `zs.supportTickets.create({ severity, subject, message, propertyIds })` (scope `support:write`) opens a
284
+ ticket; ZimmerStack attaches what its own records show. The level follows from the hotels you name: many_hotels needs two or more propertyIds or allProperties true; one_hotel needs exactly one; question takes any or none.
285
+ Open one from a person's action or from one alert, never from a loop, and never put a key, a secret or
286
+ a guest's details in the message.
287
+ - Before blaming your own code for a failure across hotels, read `zs.status.get()`: the open incidents
288
+ that touch your hotels. During one, keep what people changed and send it when it is resolved; do not
289
+ resend everything.
290
+
55
291
  ## Room types and rate plans
56
292
 
57
293
  - A hotel sells room types ("Deluxe Room") through rate plans ("Bed and breakfast"). Create or change
@@ -127,7 +363,8 @@ https://docs.zimmerstack.com/llms-full.txt
127
363
  untouched, so never refund on it. Read `stayStatus` and each room's `status`: NOSHOW gives the nights
128
364
  back (they are on sale again on every channel), UPCOMING again holds them. `changes` names what moved
129
365
  (`"stayStatus"`, `"rooms[0].status"`); `previous` is the booking as it read before, `stayStatus`
130
- included. The sandbox does not simulate one: the endpoint's Test button sends the sample.
366
+ included. On a sandbox, `zs.sandbox.bookings.noShow(bookingId)` makes the real event for a booking
367
+ simulated with `otaName: "Website"`, and `{ undo: true }` its undo.
131
368
  - A website booking takes one room off the count the channels hold, at once. A PMS that pushes absolute
132
369
  room counts must apply the booking to its own calendar BEFORE its next `zs.availability.set` or
133
370
  `zs.grid.save`, or that push puts the sold room back on sale. Read `zs.directBookings.all` before a
@@ -172,9 +409,16 @@ The package carries an MCP server for you, the agent: `npx -y @zimmerstack/conne
172
409
  connected, use it instead of guessing: `zimmerstack_reference` looks up any operation, type, limit
173
410
  or error code from the API's own contract, and `zimmerstack_sandbox_read` /
174
411
  `zimmerstack_sandbox_write` make one call on the sandbox so you can see real ids and try a body
175
- before you write the code that sends it. It works with a `zsk_test_` key only and refuses a live
176
- one. It is for building; the application you write calls the API through the client, never through
177
- these tools.
412
+ before you write the code that sends it. `zimmerstack_doctor` says what is wrong when a call is
413
+ refused or a webhook does not arrive; `zimmerstack_sandbox_limits` prints every budget and how full it
414
+ is; `zimmerstack_sandbox_simulate` makes a real booking or channel event of any type on the sandbox, and
415
+ `zimmerstack_sandbox_events` reads the ordered log, so a receiver and its catch-up can be tried end to
416
+ end. `zimmerstack_sandbox_dry_run` shows what a write would do with nothing written, and its notices;
417
+ `zimmerstack_sandbox_explain` tells one night's whole story; `zimmerstack_sandbox_close` closes or reopens
418
+ a room type everywhere; `zimmerstack_sandbox_fault` makes the sandbox's pretend channel refuse, throttle
419
+ or go down, so the code that handles a refused value or an outage can be tried before a live hotel meets
420
+ one (in your own tests: `zs.sandbox.faults.set` and `.clear`). It works with a `zsk_test_` key only and refuses a live one. It is for building; the application
421
+ you write calls the API through the client, never through these tools.
178
422
 
179
423
  ## Before you call the work done
180
424
 
@@ -187,3 +431,13 @@ these tools.
187
431
  - [ ] A PMS that pushes room counts applies every website booking to its own calendar before it pushes.
188
432
  - [ ] A website booking is cancelled only from a person's own action, with the refund they chose.
189
433
  - [ ] A room type or a rate plan is deleted only from a person's own action, after a confirmation that names it.
434
+ - [ ] The webhook receiver saves its place in the event log and catches up from it; nothing depends on a delivery arriving, or arriving in order.
435
+ - [ ] A write's answer is read: `rejected`, `rounded` and a batch that reads `failed` reach the person who saved.
436
+ - [ ] Money is handled as the API's decimal strings with the package's helpers; nothing divides by 100.
437
+ - [ ] Guest contact the application needs is copied when the booking arrives, and `contactWithheld` is handled.
438
+ - [ ] After every save of prices, room counts or stay rules, the notices (`noticesOf`) reach the person who saved.
439
+ - [ ] A button that closes a night says what it closes: one rate plan (stop-sell), the room's count (0), or both (`zs.availability.close`).
440
+ - [ ] A value shown once (a key, a connect link, a webhook secret) is taken with `shownOnce`, stored at once, and never logged.
441
+ - [ ] Code that reads `event.property` runs only after the event is known not to be an incident or a support-ticket event.
442
+ - [ ] No screen asks for, and no code stores, a booking site's password.
443
+ - [ ] `npx @zimmerstack/connect doctor` reports nothing that needs attention.