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