@zimmerstack/connect 0.0.0-stage → 0.1.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 +99 -0
- package/LICENSE +21 -0
- package/README.md +225 -2
- package/dist/cjs/client.d.ts +260 -0
- package/dist/cjs/client.js +562 -0
- package/dist/cjs/errors.d.ts +46 -0
- package/dist/cjs/errors.js +51 -0
- package/dist/cjs/generated.d.ts +1153 -0
- package/dist/cjs/generated.js +135 -0
- package/dist/cjs/grid.d.ts +105 -0
- package/dist/cjs/grid.js +135 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +30 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/webhooks.d.ts +60 -0
- package/dist/cjs/webhooks.js +103 -0
- package/dist/esm/client.d.ts +260 -0
- package/dist/esm/client.js +558 -0
- package/dist/esm/errors.d.ts +46 -0
- package/dist/esm/errors.js +46 -0
- package/dist/esm/generated.d.ts +1153 -0
- package/dist/esm/generated.js +132 -0
- package/dist/esm/grid.d.ts +105 -0
- package/dist/esm/grid.js +127 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/mcp/cli.d.ts +2 -0
- package/dist/esm/mcp/cli.js +86 -0
- package/dist/esm/mcp/key.d.ts +9 -0
- package/dist/esm/mcp/key.js +31 -0
- package/dist/esm/mcp/reference.d.ts +11 -0
- package/dist/esm/mcp/reference.generated.d.ts +33 -0
- package/dist/esm/mcp/reference.generated.js +2084 -0
- package/dist/esm/mcp/reference.js +137 -0
- package/dist/esm/mcp/server.d.ts +29 -0
- package/dist/esm/mcp/server.js +223 -0
- package/dist/esm/webhooks.d.ts +60 -0
- package/dist/esm/webhooks.js +98 -0
- package/package.json +61 -4
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { type AvailabilityWrite, type BatchStatus, type Booking, type BookingCancel, type BookingCreate, type Catalog, type ChannelBooking, type ModifierResult, type OperationKey, type Operations, type RatePlansUpsert, type RatesResendAccepted, type RatesWrite, type RestrictionsWrite, type RoomTypesUpsert, type SandboxBookingCreate, type SandboxBookingModify, type WriteAccepted } from "./generated.js";
|
|
2
|
+
import { type Grid, type GridEdits, type ModifierStep } from "./grid.js";
|
|
3
|
+
export interface ZimmerStackOptions {
|
|
4
|
+
/**
|
|
5
|
+
* `zsk_test_…` (a sandbox: nothing reaches a channel) or `zsk_live_…`. Defaults to the environment
|
|
6
|
+
* variable `ZIMMERSTACK_CONNECT_KEY`, which is where it should live: never in code, a log or a browser.
|
|
7
|
+
*/
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
/** A software vendor's company key only: the hotel every call acts on. See also `forProperty`. */
|
|
10
|
+
propertyId?: number;
|
|
11
|
+
/** Only for a local stand-in of the API while testing (http://localhost:…). The key is sent to no other host. */
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
/** A replacement for the global `fetch`, for tests. */
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
/** How long one attempt may take. Default 30 s. */
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
/** How many times a request that may pass later is sent again. Default 3 (four attempts in all), at most 5. */
|
|
18
|
+
maxRetries?: number;
|
|
19
|
+
/** The longest the client waits for a budget before giving the refusal back to you. Default 120 s. */
|
|
20
|
+
maxWaitSeconds?: number;
|
|
21
|
+
/**
|
|
22
|
+
* A live key under a test runner (NODE_ENV=test, Vitest, Jest, node --test) may read but not write,
|
|
23
|
+
* because a test that loops would change a real hotel. Set true only for a test that is meant to.
|
|
24
|
+
*/
|
|
25
|
+
allowLiveWritesInTests?: boolean;
|
|
26
|
+
/** What the client is doing, for your logs: every answer, every wait, every retry. Never carries the key. */
|
|
27
|
+
onEvent?: (event: ClientEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
export type ClientEvent = {
|
|
30
|
+
type: "response";
|
|
31
|
+
operation: string;
|
|
32
|
+
status: number;
|
|
33
|
+
attempt: number;
|
|
34
|
+
ms: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "retry";
|
|
37
|
+
operation: string;
|
|
38
|
+
attempt: number;
|
|
39
|
+
waitMs: number;
|
|
40
|
+
reason: string;
|
|
41
|
+
} | {
|
|
42
|
+
type: "pace";
|
|
43
|
+
operation: string;
|
|
44
|
+
waitMs: number;
|
|
45
|
+
};
|
|
46
|
+
/** Per-call options of a write. */
|
|
47
|
+
export interface WriteOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Your own key for this write (10 to 64 of A–Z a–z 0–9 _ -), when a retry may come from another
|
|
50
|
+
* process: the same key with the same body within 7 days replays the first answer instead of
|
|
51
|
+
* writing twice. Without one the client makes a fresh key and reuses it on its own retries.
|
|
52
|
+
*/
|
|
53
|
+
idempotencyKey?: string;
|
|
54
|
+
signal?: AbortSignal;
|
|
55
|
+
}
|
|
56
|
+
export interface ReadOptions {
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}
|
|
59
|
+
type Op<K extends OperationKey> = Operations[K];
|
|
60
|
+
/** What `request` takes for an operation: its path values, its query, its body. */
|
|
61
|
+
export type RequestArgs<K extends OperationKey> = (Op<K>["path"] extends undefined ? {
|
|
62
|
+
path?: undefined;
|
|
63
|
+
} : {
|
|
64
|
+
path: Op<K>["path"];
|
|
65
|
+
}) & (Op<K>["query"] extends undefined ? {
|
|
66
|
+
query?: undefined;
|
|
67
|
+
} : {
|
|
68
|
+
query?: Op<K>["query"];
|
|
69
|
+
}) & (Op<K>["body"] extends undefined ? {
|
|
70
|
+
body?: undefined;
|
|
71
|
+
} : {
|
|
72
|
+
body: Op<K>["body"];
|
|
73
|
+
}) & WriteOptions;
|
|
74
|
+
/**
|
|
75
|
+
* The ZimmerStack Connect API, from your server.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* import { ZimmerStack } from "@zimmerstack/connect";
|
|
79
|
+
*
|
|
80
|
+
* const zs = new ZimmerStack(); // reads ZIMMERSTACK_CONNECT_KEY
|
|
81
|
+
* const grid = await zs.grid.load("2026-12-01", "2026-12-14");
|
|
82
|
+
* await zs.grid.save({ rates: [{ ratePlanId: 901, date: "2026-12-24", rate: 5200 }] });
|
|
83
|
+
*
|
|
84
|
+
* Make one per process and reuse it: the pace it keeps is per instance.
|
|
85
|
+
*/
|
|
86
|
+
export declare class ZimmerStack {
|
|
87
|
+
#private;
|
|
88
|
+
/** "test" on a sandbox key: nothing you send reaches a channel. */
|
|
89
|
+
readonly mode: "live" | "test";
|
|
90
|
+
/** The hotel a company key acts on through this instance. */
|
|
91
|
+
readonly propertyId: number | undefined;
|
|
92
|
+
constructor(options?: ZimmerStackOptions);
|
|
93
|
+
/**
|
|
94
|
+
* A software vendor's company key: the same client, acting on one hotel. Shares this client's pace,
|
|
95
|
+
* so make as many as you have hotels.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const { properties } = await zs.properties.list();
|
|
99
|
+
* for (const p of properties) await zs.forProperty(p.id).sync.get();
|
|
100
|
+
*/
|
|
101
|
+
forProperty(propertyId: number): ZimmerStack;
|
|
102
|
+
/** Never prints the key. */
|
|
103
|
+
toJSON(): {
|
|
104
|
+
mode: string;
|
|
105
|
+
propertyId: number | undefined;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Any operation of the contract by its name, typed. The methods below are this with friendlier names;
|
|
109
|
+
* use it for an operation they do not cover.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* const sync = await zs.request("GET /sync");
|
|
113
|
+
*/
|
|
114
|
+
request<K extends OperationKey>(operation: K, ...rest: {} extends RequestArgs<K> ? [args?: RequestArgs<K>] : [args: RequestArgs<K>]): Promise<Op<K>["response"]>;
|
|
115
|
+
readonly properties: {
|
|
116
|
+
/** The hotels this key may act on. A company key names one of them on every other call (`forProperty`). */
|
|
117
|
+
list: (options?: ReadOptions) => Promise<import("./generated.js").Properties>;
|
|
118
|
+
};
|
|
119
|
+
readonly property: {
|
|
120
|
+
/** The hotel: its timezone and currency, what this key may do, its own limits, what it has used, where it stands. */
|
|
121
|
+
get: (options?: ReadOptions) => Promise<import("./generated.js").Property>;
|
|
122
|
+
};
|
|
123
|
+
readonly catalog: {
|
|
124
|
+
/** Room types and rate plans, with the numeric ids every write uses. */
|
|
125
|
+
get: (options?: ReadOptions) => Promise<Catalog>;
|
|
126
|
+
/** Create or change room types by your own `ref`. Needs the scope catalog:write. */
|
|
127
|
+
upsertRoomTypes: (body: RoomTypesUpsert, options?: WriteOptions) => Promise<import("./generated.js").CatalogUpsertResult>;
|
|
128
|
+
/** Delete a room type; its rate plans go with it. */
|
|
129
|
+
deleteRoomType: (roomTypeId: number, options?: ReadOptions) => Promise<import("./generated.js").CatalogDeleteResult>;
|
|
130
|
+
/** Create or change rate plans by your own `ref`. */
|
|
131
|
+
upsertRatePlans: (body: RatePlansUpsert, options?: WriteOptions) => Promise<import("./generated.js").CatalogUpsertResult>;
|
|
132
|
+
deleteRatePlan: (ratePlanId: number, options?: ReadOptions) => Promise<import("./generated.js").CatalogDeleteResult>;
|
|
133
|
+
};
|
|
134
|
+
readonly availability: {
|
|
135
|
+
/** Rooms left to sell per room type per night, as ZimmerStack's record holds them. Up to 500 days. */
|
|
136
|
+
get: (range?: {
|
|
137
|
+
from?: string;
|
|
138
|
+
to?: string;
|
|
139
|
+
}, options?: ReadOptions) => Promise<import("./generated.js").AvailabilityRead>;
|
|
140
|
+
/**
|
|
141
|
+
* Set rooms left to sell: absolute numbers over date ranges. Answers when the values are in
|
|
142
|
+
* ZimmerStack's record (one answer per request sent; a large write is split for you).
|
|
143
|
+
*/
|
|
144
|
+
set: (updates: AvailabilityWrite["updates"], options?: WriteOptions) => Promise<WriteAccepted[]>;
|
|
145
|
+
};
|
|
146
|
+
readonly rates: {
|
|
147
|
+
/** Nightly prices per rate plan, in MINOR units (`rateMinor`), before any channel's modifier. */
|
|
148
|
+
get: (range?: {
|
|
149
|
+
from?: string;
|
|
150
|
+
to?: string;
|
|
151
|
+
}, options?: ReadOptions) => Promise<import("./generated.js").RatesRead>;
|
|
152
|
+
/**
|
|
153
|
+
* Set nightly prices in MAJOR units over date ranges (4500 = ₹4,500.00). `currency` may be left
|
|
154
|
+
* out: the hotel's own is filled in. To close a night use `restrictions.set` with stopSell,
|
|
155
|
+
* never a zero price.
|
|
156
|
+
*/
|
|
157
|
+
set: (updates: Array<Omit<RatesWrite["updates"][number], "currency"> & {
|
|
158
|
+
currency?: string;
|
|
159
|
+
}>, options?: WriteOptions) => Promise<WriteAccepted[]>;
|
|
160
|
+
/**
|
|
161
|
+
* Send the hotel's prices to its channels again, unchanged, so nights already there pick the
|
|
162
|
+
* current modifiers up. A hotel may ask a few times a day: make it a deliberate button, never
|
|
163
|
+
* automatic. Watch `rates.dirtyCells` on `sync.get()` fall to 0.
|
|
164
|
+
*/
|
|
165
|
+
resend: (options?: WriteOptions) => Promise<RatesResendAccepted>;
|
|
166
|
+
};
|
|
167
|
+
readonly restrictions: {
|
|
168
|
+
/** The stay rules per rate plan per night; null = no rule set for that field. */
|
|
169
|
+
get: (range?: {
|
|
170
|
+
from?: string;
|
|
171
|
+
to?: string;
|
|
172
|
+
}, options?: ReadOptions) => Promise<import("./generated.js").RestrictionsRead>;
|
|
173
|
+
/** Set stay rules over date ranges: stopSell, closedToArrival, closedToDeparture, minStayArrival, minStayThrough, maxStay. */
|
|
174
|
+
set: (updates: RestrictionsWrite["updates"], options?: WriteOptions) => Promise<WriteAccepted[]>;
|
|
175
|
+
};
|
|
176
|
+
readonly sync: {
|
|
177
|
+
/** How far what you sent has travelled: cells still on their way, the last error, where the integration stands. */
|
|
178
|
+
get: (options?: ReadOptions) => Promise<import("./generated.js").SyncStatus>;
|
|
179
|
+
};
|
|
180
|
+
readonly batches: {
|
|
181
|
+
/** One write, by the `batchId` its answer carried. */
|
|
182
|
+
get: (batchId: string, options?: ReadOptions) => Promise<BatchStatus>;
|
|
183
|
+
/**
|
|
184
|
+
* Wait for a write to reach the channels, asking no more often than every 15 seconds, for at most
|
|
185
|
+
* five minutes. Returns the last status: if it is still "pending", say "still syncing" and let the
|
|
186
|
+
* person look again later. Availability lands in seconds; a full calendar of prices takes minutes.
|
|
187
|
+
*/
|
|
188
|
+
wait: (batchId: string, options?: {
|
|
189
|
+
timeoutMs?: number;
|
|
190
|
+
intervalMs?: number;
|
|
191
|
+
signal?: AbortSignal;
|
|
192
|
+
}) => Promise<BatchStatus>;
|
|
193
|
+
};
|
|
194
|
+
readonly channels: {
|
|
195
|
+
/**
|
|
196
|
+
* The connected channels (Booking.com, MakeMyTrip, …), each with the price modifier it holds:
|
|
197
|
+
* `[]` = prices go as they are; `null` = a rule set by hand that this API cannot express.
|
|
198
|
+
*/
|
|
199
|
+
list: (options?: ReadOptions) => Promise<import("./generated.js").Channels>;
|
|
200
|
+
/**
|
|
201
|
+
* Replace a channel's modifier with these steps (`[]` removes it). Needs the scope
|
|
202
|
+
* channel-modifiers:write.
|
|
203
|
+
*
|
|
204
|
+
* ONE CALL MOVES EVERY PRICE SENT TO THAT CHANNEL FROM THEN ON. Call it when a person saved the
|
|
205
|
+
* setting; never from a loop, a timer or a test against a live key. Prices already on the channel
|
|
206
|
+
* stay as they are until those nights are sent again (`rates.resend`).
|
|
207
|
+
*/
|
|
208
|
+
setModifier: (channelId: string, steps: ModifierStep[], options?: WriteOptions) => Promise<ModifierResult>;
|
|
209
|
+
};
|
|
210
|
+
readonly bookings: {
|
|
211
|
+
/** Bookings this integration created, newest first. */
|
|
212
|
+
list: (query?: Op<"GET /bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").BookingsList>;
|
|
213
|
+
/**
|
|
214
|
+
* Create a booking in the hotel's PMS. Always send `externalReference` (your own reservation id):
|
|
215
|
+
* the same value returns the same booking, which makes every retry safe.
|
|
216
|
+
*/
|
|
217
|
+
create: (body: BookingCreate, options?: WriteOptions) => Promise<Booking>;
|
|
218
|
+
get: (bookingId: number, options?: ReadOptions) => Promise<Booking>;
|
|
219
|
+
/** Cancel a booking this integration created; its nights open again on the channels. */
|
|
220
|
+
cancel: (bookingId: number, body?: BookingCancel, options?: ReadOptions) => Promise<Booking>;
|
|
221
|
+
};
|
|
222
|
+
readonly channelBookings: {
|
|
223
|
+
/** OTA bookings the channel manager delivered, in the webhook's shape. Follow `nextCursor`, or use `all`. */
|
|
224
|
+
list: (query?: Op<"GET /channel-bookings">["query"], options?: ReadOptions) => Promise<import("./generated.js").ChannelBookingsList>;
|
|
225
|
+
get: (bookingId: number, options?: ReadOptions) => Promise<ChannelBooking>;
|
|
226
|
+
/**
|
|
227
|
+
* Every OTA booking changed since `since`, page by page, for reconciling what your webhook missed.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* for await (const booking of zs.channelBookings.all({ since: lastSeen })) save(booking);
|
|
231
|
+
*/
|
|
232
|
+
all: (query?: Omit<NonNullable<Op<"GET /channel-bookings">["query"]>, "cursor">, options?: ReadOptions) => AsyncGenerator<ChannelBooking, void, undefined>;
|
|
233
|
+
};
|
|
234
|
+
readonly sandbox: {
|
|
235
|
+
bookings: {
|
|
236
|
+
list: (options?: ReadOptions) => Promise<import("./generated.js").SandboxBookingsList>;
|
|
237
|
+
/** Pretend an OTA booked: the booking, the availability moved down, and the real webhook to your endpoint. */
|
|
238
|
+
create: (body: SandboxBookingCreate, options?: WriteOptions) => Promise<import("./generated.js").SandboxBooking>;
|
|
239
|
+
cancel: (bookingId: number, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
|
|
240
|
+
modify: (bookingId: number, body: SandboxBookingModify, options?: ReadOptions) => Promise<import("./generated.js").SandboxBooking>;
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
readonly grid: {
|
|
244
|
+
/**
|
|
245
|
+
* The whole grid for a window, ready for a screen: rows are room types with their rate plans,
|
|
246
|
+
* columns are nights. Three reads (four the first time). A window may span 500 days; a screen
|
|
247
|
+
* needs 14 to 60.
|
|
248
|
+
*/
|
|
249
|
+
load: (from: string, to: string, options?: ReadOptions) => Promise<Grid>;
|
|
250
|
+
/**
|
|
251
|
+
* Save what a person changed: single nights in, the fewest ranges out, one request per resource,
|
|
252
|
+
* one after another. Each answer carries a `batchId`: the values are in ZimmerStack's record and
|
|
253
|
+
* on their way to the channels.
|
|
254
|
+
*/
|
|
255
|
+
save: (edits: GridEdits, options?: {
|
|
256
|
+
signal?: AbortSignal;
|
|
257
|
+
}) => Promise<WriteAccepted[]>;
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export {};
|