@zimmerstack/connect 0.7.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.
- package/AGENTS.md +269 -15
- package/README.md +444 -18
- package/dist/cjs/client.d.ts +503 -13
- package/dist/cjs/client.js +743 -45
- 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 +2831 -205
- package/dist/cjs/generated.js +220 -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 +503 -13
- package/dist/esm/client.js +741 -45
- 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 +2831 -205
- package/dist/esm/generated.js +219 -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 +88 -9
- package/dist/esm/mcp/reference.generated.js +4457 -969
- 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 +1 -1
package/dist/cjs/generated.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// GENERATED by scripts/generate.mjs from the Connect API's public contract (ZimmerStack Connect API v1).
|
|
3
3
|
// Do not edit: change the contract, then run `pnpm --dir apps/connect-sdk run generate`.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.OPERATIONS = exports.MODIFIER_TAKES_EFFECT = exports.SCOPES = exports.ERROR_CODES = exports.LIMITS = exports.PROPERTY_HEADER = exports.IDEMPOTENCY_HEADER = exports.API_PREFIX = exports.API_ORIGIN = exports.SDK_VERSION = void 0;
|
|
5
|
+
exports.OPERATIONS = exports.SUPPORT_SEVERITIES = exports.NOTICES = exports.MODIFIER_TAKES_EFFECT = exports.SCOPES = exports.ERROR_CODES = exports.LIMITS = exports.PROPERTY_HEADER = exports.IDEMPOTENCY_HEADER = exports.API_PREFIX = exports.API_ORIGIN = exports.SDK_VERSION = void 0;
|
|
6
6
|
/** This package's version, sent as the user agent so ZimmerStack can tell which client a request came from. */
|
|
7
|
-
exports.SDK_VERSION = "0.
|
|
7
|
+
exports.SDK_VERSION = "0.9.0";
|
|
8
8
|
/** Where the API lives. The key is sent nowhere else. */
|
|
9
9
|
exports.API_ORIGIN = "https://api.zimmerstack.com";
|
|
10
10
|
exports.API_PREFIX = "/api/v1/connect-api/v1";
|
|
@@ -19,10 +19,14 @@ exports.LIMITS = {
|
|
|
19
19
|
"propertyWritesPerMinute": 60,
|
|
20
20
|
"propertyCellsPerMinute": 20000,
|
|
21
21
|
"ipRequestsPerMinute": 240,
|
|
22
|
+
"ipAuthFailuresPerMinute": 20,
|
|
23
|
+
"keyAuthFailuresPerMinute": 5,
|
|
24
|
+
"globalUnauthenticatedPerMinute": 1200,
|
|
25
|
+
"globalRequestsPerMinute": 3000,
|
|
22
26
|
"maxUpdatesPerRequest": 1000,
|
|
23
27
|
"maxCellsPerRequest": 5000,
|
|
24
28
|
"maxBodyBytes": 1048576,
|
|
25
|
-
"horizonDays":
|
|
29
|
+
"horizonDays": 500,
|
|
26
30
|
"bookingsPerMinute": 20,
|
|
27
31
|
"propertyBookingsPerMinute": 40,
|
|
28
32
|
"propertyBookingsPerDay": 500,
|
|
@@ -74,6 +78,14 @@ exports.ERROR_CODES = [
|
|
|
74
78
|
"CATALOG_CONFLICT",
|
|
75
79
|
"CATALOG_BUSY",
|
|
76
80
|
"CHANNEL_MANAGER_ERROR",
|
|
81
|
+
"WEBHOOK_ENDPOINT_NOT_FOUND",
|
|
82
|
+
"WEBHOOK_DELIVERY_NOT_FOUND",
|
|
83
|
+
"WEBHOOK_ENDPOINT_LIMIT",
|
|
84
|
+
"WEBHOOK_ENDPOINT_NOT_ACTIVE",
|
|
85
|
+
"WEBHOOK_ENDPOINT_SUSPENDED",
|
|
86
|
+
"WEBHOOK_PAYLOAD_EXPIRED",
|
|
87
|
+
"WEBHOOK_ACCESS_ENDED",
|
|
88
|
+
"WEBHOOKS_UNAVAILABLE",
|
|
77
89
|
"PROPERTY_REQUIRED",
|
|
78
90
|
"PROPERTY_NOT_FOUND",
|
|
79
91
|
"ARI_NOT_AUTHORITATIVE",
|
|
@@ -99,7 +111,21 @@ exports.ERROR_CODES = [
|
|
|
99
111
|
"CONFIRMATION_MISMATCH",
|
|
100
112
|
"PROPERTY_NOT_REMOVABLE",
|
|
101
113
|
"PROPERTY_BUSY",
|
|
102
|
-
"PRICE_UNAVAILABLE"
|
|
114
|
+
"PRICE_UNAVAILABLE",
|
|
115
|
+
"CONNECT_LINK_NOT_FOUND",
|
|
116
|
+
"CONNECT_LINKS_UNAVAILABLE",
|
|
117
|
+
"CHANNEL_NOT_AVAILABLE",
|
|
118
|
+
"LIVE_KEY_REQUIRED",
|
|
119
|
+
"NOT_READY",
|
|
120
|
+
"KEY_NOT_FOUND",
|
|
121
|
+
"KEY_LIMIT",
|
|
122
|
+
"KEY_REVOKED",
|
|
123
|
+
"KEY_ALREADY_ROTATING",
|
|
124
|
+
"SCOPES_INVALID",
|
|
125
|
+
"ALLOWED_CIDRS_INVALID",
|
|
126
|
+
"REASON_REQUIRED",
|
|
127
|
+
"SUPPORT_TICKET_NOT_FOUND",
|
|
128
|
+
"SUPPORT_TICKET_CLOSED"
|
|
103
129
|
];
|
|
104
130
|
/** What a key may do. The hotel's owner (or, for a vendor's key, the vendor) chose them when the key was made. */
|
|
105
131
|
exports.SCOPES = [
|
|
@@ -113,16 +139,160 @@ exports.SCOPES = [
|
|
|
113
139
|
"bookings:read",
|
|
114
140
|
"bookings:write",
|
|
115
141
|
"bookings:payments",
|
|
116
|
-
"properties:write"
|
|
142
|
+
"properties:write",
|
|
143
|
+
"webhooks:manage",
|
|
144
|
+
"channels:connect",
|
|
145
|
+
"keys:manage",
|
|
146
|
+
"billing:read",
|
|
147
|
+
"support:write"
|
|
117
148
|
];
|
|
118
149
|
/** When a channel's price modifier takes effect. Show it where a person saves one. */
|
|
119
150
|
exports.MODIFIER_TAKES_EFFECT = "Saving a modifier makes the channel manager send that channel every date again, so prices already on the channel move to the new rule within minutes.";
|
|
151
|
+
/** Every notice an ARI write's answer may carry (`notices`): its stable code, its level, which writes it rides on and what it means. Branch on the code; show the notice's own message and action. */
|
|
152
|
+
exports.NOTICES = [
|
|
153
|
+
{
|
|
154
|
+
"code": "NOT_SOURCE_OF_TRUTH",
|
|
155
|
+
"level": "warning",
|
|
156
|
+
"on": "every write",
|
|
157
|
+
"means": "The hotel is not live for this software yet: prices and stay rules sent now are stored and wait for go-live, and of room counts only one that lowers what is on sale goes out."
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"code": "ROOM_TYPE_NOT_LINKED",
|
|
161
|
+
"level": "warning",
|
|
162
|
+
"on": "availability",
|
|
163
|
+
"means": "The room type has no link to the channel manager: its count is kept and sent nowhere."
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"code": "PLAN_NOT_LINKED",
|
|
167
|
+
"level": "warning",
|
|
168
|
+
"on": "rates, restrictions",
|
|
169
|
+
"means": "The rate plan has no link to the channel manager: its values are kept and sent nowhere."
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"code": "PLAN_NOT_MAPPED",
|
|
173
|
+
"level": "warning",
|
|
174
|
+
"on": "rates, restrictions",
|
|
175
|
+
"means": "The rate plan is on the channel manager and no connected channel that is switched on sells it: nothing sells or stops because of this write."
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"code": "ROOM_STILL_ON_SALE",
|
|
179
|
+
"level": "warning",
|
|
180
|
+
"on": "restrictions",
|
|
181
|
+
"means": "You stop-sold one rate plan; the room is still on sale through its other plans (otherRatePlanIds)."
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"code": "OTA_LINKED_RATES_NOT_REACHED",
|
|
185
|
+
"level": "info",
|
|
186
|
+
"on": "restrictions",
|
|
187
|
+
"means": "A stop-sell does not reach a rate an OTA links on its own side: only the room's count closes it."
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"code": "STAY_RULES_FROM_ANOTHER_PLAN",
|
|
191
|
+
"level": "warning",
|
|
192
|
+
"on": "restrictions",
|
|
193
|
+
"means": "On a channel, the OTA rate this plan sells takes its stay rules from another plan's row (otherRatePlanIds): a stay rule here alone does not reach it."
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
"code": "PER_OTA_PLANS_FOLLOW",
|
|
197
|
+
"level": "info",
|
|
198
|
+
"on": "rates, restrictions",
|
|
199
|
+
"means": "The plan has per-OTA plans: its price is copied onto them and they follow its stay rules."
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"code": "PER_OTA_PLAN_FOLLOWS_PARENT",
|
|
203
|
+
"level": "warning",
|
|
204
|
+
"on": "rates, restrictions",
|
|
205
|
+
"means": "The plan you wrote is a per-OTA plan: its parent's price and stay rules replace what is set here."
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"code": "VALUE_HELD",
|
|
209
|
+
"level": "warning",
|
|
210
|
+
"on": "rates, restrictions",
|
|
211
|
+
"means": "The value equals one the channel manager refused: it is held with its words, not sent again."
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"code": "COUNT_WAS_REFUSED",
|
|
215
|
+
"level": "warning",
|
|
216
|
+
"on": "availability",
|
|
217
|
+
"means": "The last count sent for these nights was refused by the channel manager and nothing has landed since."
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"code": "COUNT_ZERO_IS_NOT_STOP_SELL",
|
|
221
|
+
"level": "info",
|
|
222
|
+
"on": "availability",
|
|
223
|
+
"means": "You sent availability 0: a count that closes every plan and channel, and that the next OTA cancellation or your next count moves. Not a switch."
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"code": "STOP_SELL_IS_NOT_A_COUNT",
|
|
227
|
+
"level": "info",
|
|
228
|
+
"on": "restrictions",
|
|
229
|
+
"means": "You sent a stop-sell: a switch on those plans. The room's count is untouched."
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"code": "COUNT_OPEN_BUT_PLANS_STOPPED",
|
|
233
|
+
"level": "warning",
|
|
234
|
+
"on": "availability",
|
|
235
|
+
"means": "You sent a count above 0 for nights on which every plan of the room is stop-sold: the room does not sell."
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"code": "NEW_DATES_OPEN_CLOSED",
|
|
239
|
+
"level": "warning",
|
|
240
|
+
"on": "availability",
|
|
241
|
+
"means": "The hotel's rule \"new dates open closed\" will set these nights to 0 when they come on sale."
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"code": "FAR_NIGHTS_NEED_A_COUNT",
|
|
245
|
+
"level": "warning",
|
|
246
|
+
"on": "rates, restrictions",
|
|
247
|
+
"means": "A night past day 365 with no count of its own goes out closed, whatever its price or stay rules."
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"code": "ENGINE_WILL_REPRICE",
|
|
251
|
+
"level": "warning",
|
|
252
|
+
"on": "rates",
|
|
253
|
+
"means": "The hotel's pricing engine is set to win: it replaces a price sent here at its next hourly update."
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"code": "ENGINE_WILL_RECOUNT",
|
|
257
|
+
"level": "warning",
|
|
258
|
+
"on": "availability",
|
|
259
|
+
"means": "The hotel publishes the count its bookings work out: a count above 0 sent here is replaced. A 0 holds."
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"code": "DRIFT_REPAIR_OFF",
|
|
263
|
+
"level": "info",
|
|
264
|
+
"on": "rates, restrictions",
|
|
265
|
+
"means": "The hotel switched the nightly repair off: a value changed on the channel manager's side is reported, not sent again."
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
/** The three levels of a support ticket (`zs.supportTickets.create`): what each means and when ZimmerStack first replies. */
|
|
269
|
+
exports.SUPPORT_SEVERITIES = [
|
|
270
|
+
{
|
|
271
|
+
"severity": "many_hotels",
|
|
272
|
+
"name": "Many hotels",
|
|
273
|
+
"means": "2 or more of your hotels, or all of them, cannot take bookings or cannot send prices and rooms to the booking sites.",
|
|
274
|
+
"firstReply": "Within 60 minutes, 9:00 to 21:00 IST, every day. Opened outside those hours: by 10:00 IST."
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"severity": "one_hotel",
|
|
278
|
+
"name": "One hotel",
|
|
279
|
+
"means": "One hotel cannot take bookings or cannot send prices and rooms to the booking sites.",
|
|
280
|
+
"firstReply": "Within one working day."
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"severity": "question",
|
|
284
|
+
"name": "Question",
|
|
285
|
+
"means": "Anything else: how something works, a bill, a change you plan, a problem that stops nothing.",
|
|
286
|
+
"firstReply": "Within one working day."
|
|
287
|
+
}
|
|
288
|
+
];
|
|
120
289
|
/** idempotent: the server replays the stored answer when the idempotency key repeats, so the client may resend the request after a network failure. */
|
|
121
290
|
exports.OPERATIONS = {
|
|
122
291
|
"GET /properties": { idempotent: false, bodyRequired: false },
|
|
123
292
|
"POST /properties": { idempotent: true, bodyRequired: true },
|
|
124
293
|
"DELETE /properties/{propertyId}": { idempotent: false, bodyRequired: false },
|
|
125
294
|
"GET /property": { idempotent: false, bodyRequired: false },
|
|
295
|
+
"GET /limits": { idempotent: false, bodyRequired: false },
|
|
126
296
|
"GET /catalog": { idempotent: false, bodyRequired: false },
|
|
127
297
|
"PUT /catalog/room-types": { idempotent: true, bodyRequired: true },
|
|
128
298
|
"DELETE /catalog/room-types/{roomTypeId}": { idempotent: false, bodyRequired: false },
|
|
@@ -134,22 +304,64 @@ exports.OPERATIONS = {
|
|
|
134
304
|
"PUT /rates": { idempotent: true, bodyRequired: true },
|
|
135
305
|
"GET /restrictions": { idempotent: false, bodyRequired: false },
|
|
136
306
|
"PUT /restrictions": { idempotent: true, bodyRequired: true },
|
|
307
|
+
"POST /availability/close": { idempotent: true, bodyRequired: true },
|
|
308
|
+
"POST /availability/reopen": { idempotent: true, bodyRequired: true },
|
|
309
|
+
"GET /explain": { idempotent: false, bodyRequired: false },
|
|
310
|
+
"GET /sandbox/faults": { idempotent: false, bodyRequired: false },
|
|
311
|
+
"POST /sandbox/faults": { idempotent: true, bodyRequired: true },
|
|
312
|
+
"DELETE /sandbox/faults": { idempotent: false, bodyRequired: false },
|
|
137
313
|
"GET /sync": { idempotent: false, bodyRequired: false },
|
|
138
314
|
"GET /bookings": { idempotent: false, bodyRequired: false },
|
|
139
315
|
"POST /bookings": { idempotent: true, bodyRequired: true },
|
|
140
316
|
"GET /bookings/{bookingId}": { idempotent: false, bodyRequired: false },
|
|
141
|
-
"POST /bookings/{bookingId}/cancel": { idempotent:
|
|
317
|
+
"POST /bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
|
|
318
|
+
"GET /requests": { idempotent: false, bodyRequired: false },
|
|
142
319
|
"GET /channels": { idempotent: false, bodyRequired: false },
|
|
143
320
|
"PUT /channels/{channelId}/modifier": { idempotent: true, bodyRequired: true },
|
|
144
321
|
"POST /rates/resend": { idempotent: true, bodyRequired: false },
|
|
145
322
|
"GET /channel-bookings": { idempotent: false, bodyRequired: false },
|
|
146
323
|
"GET /channel-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
|
|
324
|
+
"GET /webhook-endpoints": { idempotent: false, bodyRequired: false },
|
|
325
|
+
"POST /webhook-endpoints": { idempotent: true, bodyRequired: true },
|
|
326
|
+
"GET /webhook-endpoints/{endpointId}": { idempotent: false, bodyRequired: false },
|
|
327
|
+
"PATCH /webhook-endpoints/{endpointId}": { idempotent: true, bodyRequired: true },
|
|
328
|
+
"DELETE /webhook-endpoints/{endpointId}": { idempotent: false, bodyRequired: false },
|
|
329
|
+
"POST /webhook-endpoints/{endpointId}/pause": { idempotent: true, bodyRequired: false },
|
|
330
|
+
"POST /webhook-endpoints/{endpointId}/resume": { idempotent: true, bodyRequired: false },
|
|
331
|
+
"POST /webhook-endpoints/{endpointId}/rotate-secret": { idempotent: true, bodyRequired: false },
|
|
332
|
+
"POST /webhook-endpoints/{endpointId}/test": { idempotent: true, bodyRequired: false },
|
|
333
|
+
"POST /webhook-endpoints/{endpointId}/recover": { idempotent: true, bodyRequired: true },
|
|
334
|
+
"GET /webhook-endpoints/{endpointId}/deliveries": { idempotent: false, bodyRequired: false },
|
|
335
|
+
"GET /webhook-endpoints/{endpointId}/deliveries/{deliveryId}": { idempotent: false, bodyRequired: false },
|
|
336
|
+
"POST /webhook-endpoints/{endpointId}/deliveries/{deliveryId}/redeliver": { idempotent: true, bodyRequired: false },
|
|
337
|
+
"GET /status": { idempotent: false, bodyRequired: false },
|
|
338
|
+
"GET /billing": { idempotent: false, bodyRequired: false },
|
|
339
|
+
"GET /billing/invoices": { idempotent: false, bodyRequired: false },
|
|
340
|
+
"GET /billing/next-invoice": { idempotent: false, bodyRequired: false },
|
|
341
|
+
"GET /support-tickets": { idempotent: false, bodyRequired: false },
|
|
342
|
+
"POST /support-tickets": { idempotent: true, bodyRequired: true },
|
|
343
|
+
"GET /support-tickets/{ticketId}": { idempotent: false, bodyRequired: false },
|
|
344
|
+
"POST /support-tickets/{ticketId}/messages": { idempotent: true, bodyRequired: true },
|
|
345
|
+
"POST /support-tickets/{ticketId}/close": { idempotent: true, bodyRequired: false },
|
|
346
|
+
"POST /sandbox/bookings/{bookingId}/no-show": { idempotent: true, bodyRequired: false },
|
|
347
|
+
"POST /sandbox/sync-events": { idempotent: true, bodyRequired: true },
|
|
348
|
+
"GET /events": { idempotent: false, bodyRequired: false },
|
|
147
349
|
"GET /direct-bookings": { idempotent: false, bodyRequired: false },
|
|
148
350
|
"GET /direct-bookings/{bookingId}": { idempotent: false, bodyRequired: false },
|
|
149
351
|
"POST /direct-bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
|
|
150
352
|
"GET /sandbox/bookings": { idempotent: false, bodyRequired: false },
|
|
151
353
|
"POST /sandbox/bookings": { idempotent: true, bodyRequired: true },
|
|
152
|
-
"POST /sandbox/bookings/{bookingId}/cancel": { idempotent:
|
|
153
|
-
"POST /sandbox/bookings/{bookingId}/modify": { idempotent:
|
|
354
|
+
"POST /sandbox/bookings/{bookingId}/cancel": { idempotent: true, bodyRequired: false },
|
|
355
|
+
"POST /sandbox/bookings/{bookingId}/modify": { idempotent: true, bodyRequired: true },
|
|
154
356
|
"GET /batches/{batchId}": { idempotent: false, bodyRequired: false },
|
|
357
|
+
"GET /connect-links": { idempotent: false, bodyRequired: false },
|
|
358
|
+
"POST /connect-links": { idempotent: true, bodyRequired: true },
|
|
359
|
+
"GET /connect-links/{linkId}": { idempotent: false, bodyRequired: false },
|
|
360
|
+
"POST /connect-links/{linkId}/revoke": { idempotent: true, bodyRequired: false },
|
|
361
|
+
"GET /readiness": { idempotent: false, bodyRequired: false },
|
|
362
|
+
"POST /go-live": { idempotent: true, bodyRequired: false },
|
|
363
|
+
"GET /properties/{propertyId}/keys": { idempotent: false, bodyRequired: false },
|
|
364
|
+
"POST /properties/{propertyId}/keys": { idempotent: true, bodyRequired: true },
|
|
365
|
+
"POST /properties/{propertyId}/keys/{keyId}/rotate": { idempotent: true, bodyRequired: false },
|
|
366
|
+
"POST /properties/{propertyId}/keys/{keyId}/revoke": { idempotent: true, bodyRequired: true },
|
|
155
367
|
};
|
package/dist/cjs/grid.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface GridEdits {
|
|
|
39
39
|
date: string;
|
|
40
40
|
available: number;
|
|
41
41
|
}>;
|
|
42
|
-
/** `rate` in MAJOR units.
|
|
42
|
+
/** `rate` in MAJOR units. `stopSell` closes one rate plan on a night; 0 rooms in `availability` closes the room type. Never a zero price. */
|
|
43
43
|
rates?: Array<{
|
|
44
44
|
ratePlanId: number;
|
|
45
45
|
date: string;
|
|
@@ -84,6 +84,11 @@ export declare function toRanges<V>(cells: ReadonlyArray<{
|
|
|
84
84
|
date: string;
|
|
85
85
|
value: V;
|
|
86
86
|
}>): Array<Range<V>>;
|
|
87
|
+
/** How many cells (one row on one night) a list of updates names: what the API's cells budget counts. */
|
|
88
|
+
export declare function cellsOf(updates: ReadonlyArray<{
|
|
89
|
+
dateFrom: string;
|
|
90
|
+
dateTo: string;
|
|
91
|
+
}>): number;
|
|
87
92
|
/**
|
|
88
93
|
* Split updates so one request stays inside what the API takes: at most 1,000 updates and 5,000 cells
|
|
89
94
|
* (a cell is one row on one night). A single update larger than a request is cut into shorter ranges.
|
package/dist/cjs/grid.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.eachDate = eachDate;
|
|
|
4
4
|
exports.addDays = addDays;
|
|
5
5
|
exports.buildGrid = buildGrid;
|
|
6
6
|
exports.toRanges = toRanges;
|
|
7
|
+
exports.cellsOf = cellsOf;
|
|
7
8
|
exports.chunk = chunk;
|
|
8
9
|
exports.channelPrice = channelPrice;
|
|
9
10
|
const generated_ts_1 = require("./generated.js");
|
|
@@ -90,6 +91,13 @@ function stable(value) {
|
|
|
90
91
|
return JSON.stringify(entries);
|
|
91
92
|
}
|
|
92
93
|
const nights = (range) => Math.max(1, Math.round((ms(range.dateTo) - ms(range.dateFrom)) / DAY) + 1);
|
|
94
|
+
/** How many cells (one row on one night) a list of updates names: what the API's cells budget counts. */
|
|
95
|
+
function cellsOf(updates) {
|
|
96
|
+
let cells = 0;
|
|
97
|
+
for (const update of updates)
|
|
98
|
+
cells += nights(update);
|
|
99
|
+
return cells;
|
|
100
|
+
}
|
|
93
101
|
/**
|
|
94
102
|
* Split updates so one request stays inside what the API takes: at most 1,000 updates and 5,000 cells
|
|
95
103
|
* (a cell is one row on one night). A single update larger than a request is cut into shorter ranges.
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -5,12 +5,21 @@
|
|
|
5
5
|
* mobile app, a repository or a log line.
|
|
6
6
|
*/
|
|
7
7
|
export { ZimmerStack } from "./client.js";
|
|
8
|
-
export type { ClientEvent, RatePlanInput, ReadOptions, RequestArgs, RoomTypeInput, StructureSaved, WriteOptions, ZimmerStackOptions } from "./client.js";
|
|
8
|
+
export type { ClientEvent, CloseDone, ClosePreview, CloseRequest, LimitNow, LimitsNow, RatePlanInput, ReadOptions, ReopenRequest, RequestArgs, RoomTypeInput, StructureSaved, WriteOptions, ZimmerStackOptions } from "./client.js";
|
|
9
|
+
export { diagnose, formatDoctorReport } from "./doctor.js";
|
|
10
|
+
export type { DoctorBudget, DoctorCheck, DoctorFinding, DoctorOptions, DoctorReport } from "./doctor.js";
|
|
9
11
|
export { ZimmerStackError, ZimmerStackUsageError } from "./errors.js";
|
|
10
12
|
export type { LocalErrorCode } from "./errors.js";
|
|
11
|
-
export { addDays, buildGrid, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
|
|
13
|
+
export { addDays, buildGrid, cellsOf, channelPrice, chunk, eachDate, toRanges } from "./grid.js";
|
|
12
14
|
export type { Grid, GridEdits, ModifierStep, Range, Restrictions } from "./grid.js";
|
|
13
|
-
export {
|
|
14
|
-
export type {
|
|
15
|
-
export {
|
|
15
|
+
export { checkKey } from "./key.js";
|
|
16
|
+
export type { KeyCheck } from "./key.js";
|
|
17
|
+
export { findNotice, isWritePreview, noticeMeaning, noticesOf, noticesOmittedFrom, warningsOf } from "./notices.js";
|
|
18
|
+
export type { NoticeCarrier } from "./notices.js";
|
|
19
|
+
export { shownOnce, withoutShownOnce, ZimmerStackShownOnceError } from "./shownOnce.js";
|
|
20
|
+
export type { ShownOnceAnswer, ShownOnceKind } from "./shownOnce.js";
|
|
21
|
+
export { addAmounts, amountFromHundredths, amountFromMinorUnits, amountToMinorUnits, compareAmounts, formatAmount, multiplyAmount, subtractAmounts, toAmount } from "./money.js";
|
|
22
|
+
export { BOOKING_EVENT_TYPES, CONNECT_EVENT_TYPES, DRIFT_EVENT_TYPES, INCIDENT_EVENT_TYPES, OTA_BOOKING_EVENT_TYPES, SUPPORT_TICKET_EVENT_TYPES, SYNC_EVENT_TYPES, WEBSITE_BOOKING_EVENT_TYPES, isConnectEvent, isDriftEvent, isIncidentEvent, isOtaBookingEvent, isSupportTicketEvent, isSyncEvent, isWebsiteBookingEvent, verifyWebhook, ZimmerStackWebhookError, } from "./webhooks.js";
|
|
23
|
+
export type { BookingEvent, BookingEventType, ConnectEvent, ConnectEventType, DriftEvent, DriftEventType, IncidentEvent, IncidentEventType, IncidentInEvent, OtaBookingEvent, OtaBookingEventType, SupportTicketEvent, SupportTicketEventType, SyncEvent, SyncEventType, TicketInEvent, WebhookEvent, WebhookEventType, WebsiteBookingEvent, WebsiteBookingEventType, } from "./webhooks.js";
|
|
24
|
+
export { ERROR_CODES, LIMITS, MODIFIER_TAKES_EFFECT, NOTICES, SCOPES, SDK_VERSION, SUPPORT_SEVERITIES } from "./generated.js";
|
|
16
25
|
export type * from "./generated.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LIMITS = exports.ERROR_CODES = exports.ZimmerStackWebhookError = exports.verifyWebhook = exports.isWebsiteBookingEvent = exports.isSyncEvent = exports.isSupportTicketEvent = exports.isOtaBookingEvent = exports.isIncidentEvent = exports.isDriftEvent = exports.isConnectEvent = exports.WEBSITE_BOOKING_EVENT_TYPES = exports.SYNC_EVENT_TYPES = exports.SUPPORT_TICKET_EVENT_TYPES = exports.OTA_BOOKING_EVENT_TYPES = exports.INCIDENT_EVENT_TYPES = exports.DRIFT_EVENT_TYPES = exports.CONNECT_EVENT_TYPES = exports.BOOKING_EVENT_TYPES = exports.toAmount = exports.subtractAmounts = exports.multiplyAmount = exports.formatAmount = exports.compareAmounts = exports.amountToMinorUnits = exports.amountFromMinorUnits = exports.amountFromHundredths = exports.addAmounts = exports.ZimmerStackShownOnceError = exports.withoutShownOnce = exports.shownOnce = exports.warningsOf = exports.noticesOmittedFrom = exports.noticesOf = exports.noticeMeaning = exports.isWritePreview = exports.findNotice = exports.checkKey = exports.toRanges = exports.eachDate = exports.chunk = exports.channelPrice = exports.cellsOf = exports.buildGrid = exports.addDays = exports.ZimmerStackUsageError = exports.ZimmerStackError = exports.formatDoctorReport = exports.diagnose = exports.ZimmerStack = void 0;
|
|
4
|
+
exports.SUPPORT_SEVERITIES = exports.SDK_VERSION = exports.SCOPES = exports.NOTICES = exports.MODIFIER_TAKES_EFFECT = void 0;
|
|
4
5
|
/**
|
|
5
6
|
* @zimmerstack/connect: the ZimmerStack Connect API from your server.
|
|
6
7
|
*
|
|
@@ -9,21 +10,58 @@ exports.SDK_VERSION = exports.SCOPES = exports.MODIFIER_TAKES_EFFECT = exports.L
|
|
|
9
10
|
*/
|
|
10
11
|
var client_ts_1 = require("./client.js");
|
|
11
12
|
Object.defineProperty(exports, "ZimmerStack", { enumerable: true, get: function () { return client_ts_1.ZimmerStack; } });
|
|
13
|
+
var doctor_ts_1 = require("./doctor.js");
|
|
14
|
+
Object.defineProperty(exports, "diagnose", { enumerable: true, get: function () { return doctor_ts_1.diagnose; } });
|
|
15
|
+
Object.defineProperty(exports, "formatDoctorReport", { enumerable: true, get: function () { return doctor_ts_1.formatDoctorReport; } });
|
|
12
16
|
var errors_ts_1 = require("./errors.js");
|
|
13
17
|
Object.defineProperty(exports, "ZimmerStackError", { enumerable: true, get: function () { return errors_ts_1.ZimmerStackError; } });
|
|
14
18
|
Object.defineProperty(exports, "ZimmerStackUsageError", { enumerable: true, get: function () { return errors_ts_1.ZimmerStackUsageError; } });
|
|
15
19
|
var grid_ts_1 = require("./grid.js");
|
|
16
20
|
Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return grid_ts_1.addDays; } });
|
|
17
21
|
Object.defineProperty(exports, "buildGrid", { enumerable: true, get: function () { return grid_ts_1.buildGrid; } });
|
|
22
|
+
Object.defineProperty(exports, "cellsOf", { enumerable: true, get: function () { return grid_ts_1.cellsOf; } });
|
|
18
23
|
Object.defineProperty(exports, "channelPrice", { enumerable: true, get: function () { return grid_ts_1.channelPrice; } });
|
|
19
24
|
Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return grid_ts_1.chunk; } });
|
|
20
25
|
Object.defineProperty(exports, "eachDate", { enumerable: true, get: function () { return grid_ts_1.eachDate; } });
|
|
21
26
|
Object.defineProperty(exports, "toRanges", { enumerable: true, get: function () { return grid_ts_1.toRanges; } });
|
|
27
|
+
var key_ts_1 = require("./key.js");
|
|
28
|
+
Object.defineProperty(exports, "checkKey", { enumerable: true, get: function () { return key_ts_1.checkKey; } });
|
|
29
|
+
var notices_ts_1 = require("./notices.js");
|
|
30
|
+
Object.defineProperty(exports, "findNotice", { enumerable: true, get: function () { return notices_ts_1.findNotice; } });
|
|
31
|
+
Object.defineProperty(exports, "isWritePreview", { enumerable: true, get: function () { return notices_ts_1.isWritePreview; } });
|
|
32
|
+
Object.defineProperty(exports, "noticeMeaning", { enumerable: true, get: function () { return notices_ts_1.noticeMeaning; } });
|
|
33
|
+
Object.defineProperty(exports, "noticesOf", { enumerable: true, get: function () { return notices_ts_1.noticesOf; } });
|
|
34
|
+
Object.defineProperty(exports, "noticesOmittedFrom", { enumerable: true, get: function () { return notices_ts_1.noticesOmittedFrom; } });
|
|
35
|
+
Object.defineProperty(exports, "warningsOf", { enumerable: true, get: function () { return notices_ts_1.warningsOf; } });
|
|
36
|
+
var shownOnce_ts_1 = require("./shownOnce.js");
|
|
37
|
+
Object.defineProperty(exports, "shownOnce", { enumerable: true, get: function () { return shownOnce_ts_1.shownOnce; } });
|
|
38
|
+
Object.defineProperty(exports, "withoutShownOnce", { enumerable: true, get: function () { return shownOnce_ts_1.withoutShownOnce; } });
|
|
39
|
+
Object.defineProperty(exports, "ZimmerStackShownOnceError", { enumerable: true, get: function () { return shownOnce_ts_1.ZimmerStackShownOnceError; } });
|
|
40
|
+
var money_ts_1 = require("./money.js");
|
|
41
|
+
Object.defineProperty(exports, "addAmounts", { enumerable: true, get: function () { return money_ts_1.addAmounts; } });
|
|
42
|
+
Object.defineProperty(exports, "amountFromHundredths", { enumerable: true, get: function () { return money_ts_1.amountFromHundredths; } });
|
|
43
|
+
Object.defineProperty(exports, "amountFromMinorUnits", { enumerable: true, get: function () { return money_ts_1.amountFromMinorUnits; } });
|
|
44
|
+
Object.defineProperty(exports, "amountToMinorUnits", { enumerable: true, get: function () { return money_ts_1.amountToMinorUnits; } });
|
|
45
|
+
Object.defineProperty(exports, "compareAmounts", { enumerable: true, get: function () { return money_ts_1.compareAmounts; } });
|
|
46
|
+
Object.defineProperty(exports, "formatAmount", { enumerable: true, get: function () { return money_ts_1.formatAmount; } });
|
|
47
|
+
Object.defineProperty(exports, "multiplyAmount", { enumerable: true, get: function () { return money_ts_1.multiplyAmount; } });
|
|
48
|
+
Object.defineProperty(exports, "subtractAmounts", { enumerable: true, get: function () { return money_ts_1.subtractAmounts; } });
|
|
49
|
+
Object.defineProperty(exports, "toAmount", { enumerable: true, get: function () { return money_ts_1.toAmount; } });
|
|
22
50
|
var webhooks_ts_1 = require("./webhooks.js");
|
|
23
51
|
Object.defineProperty(exports, "BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.BOOKING_EVENT_TYPES; } });
|
|
52
|
+
Object.defineProperty(exports, "CONNECT_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.CONNECT_EVENT_TYPES; } });
|
|
53
|
+
Object.defineProperty(exports, "DRIFT_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.DRIFT_EVENT_TYPES; } });
|
|
54
|
+
Object.defineProperty(exports, "INCIDENT_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.INCIDENT_EVENT_TYPES; } });
|
|
24
55
|
Object.defineProperty(exports, "OTA_BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.OTA_BOOKING_EVENT_TYPES; } });
|
|
56
|
+
Object.defineProperty(exports, "SUPPORT_TICKET_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.SUPPORT_TICKET_EVENT_TYPES; } });
|
|
57
|
+
Object.defineProperty(exports, "SYNC_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.SYNC_EVENT_TYPES; } });
|
|
25
58
|
Object.defineProperty(exports, "WEBSITE_BOOKING_EVENT_TYPES", { enumerable: true, get: function () { return webhooks_ts_1.WEBSITE_BOOKING_EVENT_TYPES; } });
|
|
59
|
+
Object.defineProperty(exports, "isConnectEvent", { enumerable: true, get: function () { return webhooks_ts_1.isConnectEvent; } });
|
|
60
|
+
Object.defineProperty(exports, "isDriftEvent", { enumerable: true, get: function () { return webhooks_ts_1.isDriftEvent; } });
|
|
61
|
+
Object.defineProperty(exports, "isIncidentEvent", { enumerable: true, get: function () { return webhooks_ts_1.isIncidentEvent; } });
|
|
26
62
|
Object.defineProperty(exports, "isOtaBookingEvent", { enumerable: true, get: function () { return webhooks_ts_1.isOtaBookingEvent; } });
|
|
63
|
+
Object.defineProperty(exports, "isSupportTicketEvent", { enumerable: true, get: function () { return webhooks_ts_1.isSupportTicketEvent; } });
|
|
64
|
+
Object.defineProperty(exports, "isSyncEvent", { enumerable: true, get: function () { return webhooks_ts_1.isSyncEvent; } });
|
|
27
65
|
Object.defineProperty(exports, "isWebsiteBookingEvent", { enumerable: true, get: function () { return webhooks_ts_1.isWebsiteBookingEvent; } });
|
|
28
66
|
Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhooks_ts_1.verifyWebhook; } });
|
|
29
67
|
Object.defineProperty(exports, "ZimmerStackWebhookError", { enumerable: true, get: function () { return webhooks_ts_1.ZimmerStackWebhookError; } });
|
|
@@ -31,5 +69,7 @@ var generated_ts_1 = require("./generated.js");
|
|
|
31
69
|
Object.defineProperty(exports, "ERROR_CODES", { enumerable: true, get: function () { return generated_ts_1.ERROR_CODES; } });
|
|
32
70
|
Object.defineProperty(exports, "LIMITS", { enumerable: true, get: function () { return generated_ts_1.LIMITS; } });
|
|
33
71
|
Object.defineProperty(exports, "MODIFIER_TAKES_EFFECT", { enumerable: true, get: function () { return generated_ts_1.MODIFIER_TAKES_EFFECT; } });
|
|
72
|
+
Object.defineProperty(exports, "NOTICES", { enumerable: true, get: function () { return generated_ts_1.NOTICES; } });
|
|
34
73
|
Object.defineProperty(exports, "SCOPES", { enumerable: true, get: function () { return generated_ts_1.SCOPES; } });
|
|
35
74
|
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return generated_ts_1.SDK_VERSION; } });
|
|
75
|
+
Object.defineProperty(exports, "SUPPORT_SEVERITIES", { enumerable: true, get: function () { return generated_ts_1.SUPPORT_SEVERITIES; } });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a ZimmerStack key looks like, checked without sending it anywhere.
|
|
3
|
+
*
|
|
4
|
+
* A key made since 22 Nov 2026 is `zsk_live_` (or `zsk_test_` on a sandbox), 40 letters and digits, then
|
|
5
|
+
* 6 characters that are a checksum of everything before them (CRC32, written in base 62). So a key that
|
|
6
|
+
* was mistyped or cut short can be told from a real one offline, before any request. A key made before
|
|
7
|
+
* that day is the prefix and 43 characters with no checksum; it keeps working until it is rotated.
|
|
8
|
+
*
|
|
9
|
+
* The checksum is not a secret and proves nothing about who holds the key. It says only "this was made
|
|
10
|
+
* by ZimmerStack and not mistyped". Nothing here ever returns or prints the key itself.
|
|
11
|
+
*/
|
|
12
|
+
/** The six characters a key ends in: the CRC32 of what comes before them, in base 62, zero-padded. */
|
|
13
|
+
export declare function keyChecksum(head: string): string;
|
|
14
|
+
/** What `checkKey` found. `message` is for a person and never contains the key. */
|
|
15
|
+
export type KeyCheck = {
|
|
16
|
+
ok: true;
|
|
17
|
+
/** "test": a sandbox key, nothing it sends reaches a booking site. "live": a real hotel. */
|
|
18
|
+
mode: "live" | "test";
|
|
19
|
+
/** "checksummed": made since 22 Nov 2026. "legacy": made before, no checksum; it works until it is rotated. */
|
|
20
|
+
format: "checksummed" | "legacy";
|
|
21
|
+
message: string;
|
|
22
|
+
} | {
|
|
23
|
+
ok: false;
|
|
24
|
+
mode: "live" | "test" | null;
|
|
25
|
+
/** empty · not-a-key (no zsk_ prefix) · wrong-length (cut short, or something extra around it) · bad-checksum (a character changed) */
|
|
26
|
+
problem: "empty" | "not-a-key" | "wrong-length" | "bad-checksum";
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Is this string a ZimmerStack key? Checked here, with no request: the key is sent nowhere.
|
|
31
|
+
*
|
|
32
|
+
* Use it where a person pastes a key (a settings screen, a deploy script), so a slip is caught at once
|
|
33
|
+
* and never spends a failed sign-in. It cannot say whether the key is still valid: only a request can.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const check = checkKey(process.env.ZIMMERSTACK_CONNECT_KEY);
|
|
37
|
+
* if (!check.ok) throw new Error(check.message);
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkKey(key: unknown): KeyCheck;
|
package/dist/cjs/key.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* What a ZimmerStack key looks like, checked without sending it anywhere.
|
|
4
|
+
*
|
|
5
|
+
* A key made since 22 Nov 2026 is `zsk_live_` (or `zsk_test_` on a sandbox), 40 letters and digits, then
|
|
6
|
+
* 6 characters that are a checksum of everything before them (CRC32, written in base 62). So a key that
|
|
7
|
+
* was mistyped or cut short can be told from a real one offline, before any request. A key made before
|
|
8
|
+
* that day is the prefix and 43 characters with no checksum; it keeps working until it is rotated.
|
|
9
|
+
*
|
|
10
|
+
* The checksum is not a secret and proves nothing about who holds the key. It says only "this was made
|
|
11
|
+
* by ZimmerStack and not mistyped". Nothing here ever returns or prints the key itself.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.keyChecksum = keyChecksum;
|
|
15
|
+
exports.checkKey = checkKey;
|
|
16
|
+
const LEGACY = /^zsk_(live|test)_[A-Za-z0-9_-]{43}$/;
|
|
17
|
+
const CHECKSUMMED = /^zsk_(live|test)_[A-Za-z0-9]{46}$/;
|
|
18
|
+
const PREFIX = /^zsk_(live|test)_/;
|
|
19
|
+
const CHECKSUM_CHARS = 6;
|
|
20
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
21
|
+
let table;
|
|
22
|
+
/** CRC32 (IEEE, the zlib one) of a string's bytes. A key is plain ASCII, so a character is a byte. */
|
|
23
|
+
function crc32(text) {
|
|
24
|
+
table ??= Array.from({ length: 256 }, (_, n) => {
|
|
25
|
+
let c = n;
|
|
26
|
+
for (let k = 0; k < 8; k++)
|
|
27
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
28
|
+
return c >>> 0;
|
|
29
|
+
});
|
|
30
|
+
let crc = 0xffffffff;
|
|
31
|
+
for (let i = 0; i < text.length; i++)
|
|
32
|
+
crc = table[(crc ^ text.charCodeAt(i)) & 0xff] ^ (crc >>> 8);
|
|
33
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
34
|
+
}
|
|
35
|
+
/** The six characters a key ends in: the CRC32 of what comes before them, in base 62, zero-padded. */
|
|
36
|
+
function keyChecksum(head) {
|
|
37
|
+
let n = crc32(head);
|
|
38
|
+
let out = "";
|
|
39
|
+
while (n > 0) {
|
|
40
|
+
out = BASE62[n % 62] + out;
|
|
41
|
+
n = Math.floor(n / 62);
|
|
42
|
+
}
|
|
43
|
+
return out.padStart(CHECKSUM_CHARS, "0");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Is this string a ZimmerStack key? Checked here, with no request: the key is sent nowhere.
|
|
47
|
+
*
|
|
48
|
+
* Use it where a person pastes a key (a settings screen, a deploy script), so a slip is caught at once
|
|
49
|
+
* and never spends a failed sign-in. It cannot say whether the key is still valid: only a request can.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* const check = checkKey(process.env.ZIMMERSTACK_CONNECT_KEY);
|
|
53
|
+
* if (!check.ok) throw new Error(check.message);
|
|
54
|
+
*/
|
|
55
|
+
function checkKey(key) {
|
|
56
|
+
const value = typeof key === "string" ? key.trim() : "";
|
|
57
|
+
if (!value)
|
|
58
|
+
return { ok: false, mode: null, problem: "empty", message: "No key was given. A ZimmerStack key starts with zsk_test_ (a sandbox) or zsk_live_." };
|
|
59
|
+
const prefix = PREFIX.exec(value);
|
|
60
|
+
if (!prefix) {
|
|
61
|
+
return { ok: false, mode: null, problem: "not-a-key", message: "This is not a ZimmerStack key: one starts with zsk_test_ (a sandbox) or zsk_live_ (a real hotel)." };
|
|
62
|
+
}
|
|
63
|
+
const mode = prefix[1];
|
|
64
|
+
const what = mode === "test" ? "a sandbox key (zsk_test_)" : "a live key (zsk_live_)";
|
|
65
|
+
if (CHECKSUMMED.test(value)) {
|
|
66
|
+
if (keyChecksum(value.slice(0, -CHECKSUM_CHARS)) === value.slice(-CHECKSUM_CHARS))
|
|
67
|
+
return { ok: true, mode, format: "checksummed", message: `This is ${what}, and its checksum holds.` };
|
|
68
|
+
return {
|
|
69
|
+
ok: false,
|
|
70
|
+
mode,
|
|
71
|
+
problem: "bad-checksum",
|
|
72
|
+
message: "The key's last six characters are a checksum of the rest, and they do not match: a character was mistyped or changed. Copy the whole key again from where it was shown.",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (LEGACY.test(value)) {
|
|
76
|
+
return { ok: true, mode, format: "legacy", message: `This is ${what} in the format used before 22 Nov 2026. It keeps working; rotating it gives you a key whose typing slips are caught before they are sent.` };
|
|
77
|
+
}
|
|
78
|
+
const length = value.length - prefix[0].length;
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
mode,
|
|
82
|
+
problem: "wrong-length",
|
|
83
|
+
message: `This starts like a ZimmerStack key but is not one: after the prefix a key has 46 letters and digits (43 characters on a key made before 22 Nov 2026), and this one has ${length}${/[^A-Za-z0-9_-]/.test(value.slice(prefix[0].length)) ? ", with a character a key never contains" : ""}. It was cut short, or something was copied with it (a quote, a space, a line break).`,
|
|
84
|
+
};
|
|
85
|
+
}
|